在springmvc的配置文件中加上这一段即可

<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" >
<!-- 本文关键内容-->
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter" >
<property name="supportedMediaTypes">
<value>text/html;charset=UTF-8</value>
</property>
</bean>
</list>
</property> <!-- 支持@DateTimeFormat(pattern="yyyy-MM-dd")等注解 2015年7月31日11:07:03 liuyx-->
<property name="webBindingInitializer">
<bean class="org.springframework.web.bind.support.ConfigurableWebBindingInitializer">
<property name="conversionService">
<bean class="org.springframework.format.support.FormattingConversionServiceFactoryBean"></bean>
</property>
</bean>
</property>
</bean>

springMVC 【@response 返回对象自动变成json并且防止乱码】 & 【配置支持实体类中的@DateTimeFormat注解】的更多相关文章

  1. response 返回js的alert()语句,中文乱码如何解决

    response 返回js的alert()语句,中文乱码如何解决, 步骤1:在后台加上如下代码: response.setCharacterEncoding("utf-8"); r ...

  2. Mybatis自动生成xml文件、dao接口、实体类

    Mybatis可以通过逆向工程,实现自动生成xml文件.dao接口.实体类 以下使用的是Intellij Idea进行自动生成 一.首先,要在pom.xml中导入插件,在<build>中加 ...

  3. MVC 返回对象换成json

    错误界面: 这个就是返回对象没有转换成json 就是要再返回的头部添加application/json 代码: using System; using System.Collections.Gener ...

  4. Springmvc responsebody 返回对象属性 是date日期格式时 如何返回给前台自己想要的形式

    1添加依赖 <!-- Jackson Json处理工具包 -->            <dependency>              <groupId>org ...

  5. Spring 自动转配类 在类中使用@Bean 注解进行转配但是需要排除该类说明

    在spring中可以使用 @Component @Configuration @Bean(实例化后返回该bean)进行类实例的自动装配. 需求: 排除指定需要自动转配的类. 说明: 1.在以上注解中  ...

  6. JSON.net 在实体类中自定义日期的格式

    定义日期格式转换类,其继承 IsoDateTimeConverter,代码如下: public class DateTimeConverter : IsoDateTimeConverter { pub ...

  7. 将对象转为数组方法:延伸array_map函数在PHP类中调用内部方法

    public static function objectToArray($d) { if (is_object($d)) { $d = get_object_vars($d); } if (is_a ...

  8. 【java】实体类中 Set<对象> 按照对象的某个字段对set排序

    背景: User实体类 有个属性是 Set<PositionChange> 职位变更字段 如下: PositionChange实体类  有个属性是positionStartDate   什 ...

  9. 在MyEclipse的Maven环境下,使用mybatis-generator插件自动生成映射文件(接口)及实体类

    在数据表比较多的情况下,手动编写sql映射文件和实体类,实在太多过繁琐,而mybatis-generator能自动生成这此东西,减少了重复性的工作量.mybatis-generator的配置容易出现问 ...

随机推荐

  1. What does this bit-manipulating function do?

    http://stackoverflow.com/questions/8637142/what-does-this-bit-manipulating-function-do unsigned long ...

  2. How do I list all fields of an object in Objective-C?

    http://stackoverflow.com/questions/1213901/how-do-i-list-all-fields-of-an-object-in-objective-c As m ...

  3. V4L2 camera 驱动 capture测试程序【转】

    转自:http://blog.csdn.net/kickxxx/article/details/6336346 在网上找了一个测试程序, 看了看,是根据capture.c修改的.测试步骤如下 . gc ...

  4. List的set和add方法

    问题描述:[相机]打开记录拍摄地理位置后拍照详情中少“宽度”属性; 原因分析:在listview动态刷新时用set(index,elemet)方法替换了宽度及其值: 解决方法:改为add(index, ...

  5. redis 单机模拟 cluster集群

    一.redis-cluster设计 Redis集群搭建的方式有多种,例如使用zookeeper等,但从redis 3.0之后版本支持redis-cluster集群,Redis-Cluster采用无中心 ...

  6. Python基础-列表、元祖

    1. 列表.元组操作 列表是我们最以后最常用的数据类型之一,通过列表可以对数据实现最方便的存储.修改等操作 定义列表 names = ['Alex',"Tenglan",'Eric ...

  7. wsgi的学习(1):什么是WSGI

    本文来自:http://www.nowamagic.net/academy/detail/1330310 WSGI,全程是:Web Server Gateway Interface,或者python  ...

  8. blog postman 翻译(2):postman中新增request attributes 的描述(desc)

    blog的原文链接是:http://blog.getpostman.com/2017/06/03/descriptions-for-request-attributes-in-postman/ pos ...

  9. 计蒜客 17119.Trig Function-切比雪夫多项式+乘法逆元 (2017 ACM-ICPC 亚洲区(西安赛区)网络赛 F)

    哈哈哈哈哈哈哈哈哈哈哈哈,终于把这道题补出来了_(:з」∠)_ 来写题解啦. _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ _(:з」∠)_ 哈哈哈哈哈哈,从9月16日打了这 ...

  10. Python的网络编程[1] -> FTP 协议[0] -> FTP 的基本理论

    FTP协议 / FTP Protocol FTP全称为File Transfer Protocol(文件传输协议),常用于Internet上控制文件的双向传输,常用的操作有上传和下载.基于TCP/IP ...