springMVC 【@response 返回对象自动变成json并且防止乱码】 & 【配置支持实体类中的@DateTimeFormat注解】
在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注解】的更多相关文章
- response 返回js的alert()语句,中文乱码如何解决
response 返回js的alert()语句,中文乱码如何解决, 步骤1:在后台加上如下代码: response.setCharacterEncoding("utf-8"); r ...
- Mybatis自动生成xml文件、dao接口、实体类
Mybatis可以通过逆向工程,实现自动生成xml文件.dao接口.实体类 以下使用的是Intellij Idea进行自动生成 一.首先,要在pom.xml中导入插件,在<build>中加 ...
- MVC 返回对象换成json
错误界面: 这个就是返回对象没有转换成json 就是要再返回的头部添加application/json 代码: using System; using System.Collections.Gener ...
- Springmvc responsebody 返回对象属性 是date日期格式时 如何返回给前台自己想要的形式
1添加依赖 <!-- Jackson Json处理工具包 --> <dependency> <groupId>org ...
- Spring 自动转配类 在类中使用@Bean 注解进行转配但是需要排除该类说明
在spring中可以使用 @Component @Configuration @Bean(实例化后返回该bean)进行类实例的自动装配. 需求: 排除指定需要自动转配的类. 说明: 1.在以上注解中 ...
- JSON.net 在实体类中自定义日期的格式
定义日期格式转换类,其继承 IsoDateTimeConverter,代码如下: public class DateTimeConverter : IsoDateTimeConverter { pub ...
- 将对象转为数组方法:延伸array_map函数在PHP类中调用内部方法
public static function objectToArray($d) { if (is_object($d)) { $d = get_object_vars($d); } if (is_a ...
- 【java】实体类中 Set<对象> 按照对象的某个字段对set排序
背景: User实体类 有个属性是 Set<PositionChange> 职位变更字段 如下: PositionChange实体类 有个属性是positionStartDate 什 ...
- 在MyEclipse的Maven环境下,使用mybatis-generator插件自动生成映射文件(接口)及实体类
在数据表比较多的情况下,手动编写sql映射文件和实体类,实在太多过繁琐,而mybatis-generator能自动生成这此东西,减少了重复性的工作量.mybatis-generator的配置容易出现问 ...
随机推荐
- (七)ubuntu下编译openwrt内核的环境配置
首先安装基本开发环境: sudo apt-get install ssh vim samba tftp nfs 安装编译openwrt须要的包: 解压openwrt包编译出错: Build depen ...
- 【转】Hadoop安装教程_单机/伪分布式配置_Hadoop2.6.0/Ubuntu14.04
原文链接:http://dblab.xmu.edu.cn/blog/install-hadoop/ 当开始着手实践 Hadoop 时,安装 Hadoop 往往会成为新手的一道门槛.尽管安装其实很简单, ...
- python 666
运行下面代码会输出什么? __builtins__.我们来运行下这行代码看看="666" #!/usr/bin/env python # encoding: utf-8 def _ ...
- ubuntu 开启PHP CURL支持
sudo apt-get install php5-curl sudo service apache2 restart
- NetStream配置
http://support.huawei.com/enterprise/docinforeader!loadDocument1.action?contentId=DOC1000067951& ...
- Flask的上下文管理机制
前引 在了解flask上下文管理机制之前,先来一波必知必会的知识点. 面向对象双下方法 首先,先来聊一聊面向对象中的一些特殊的双下划线方法,比如__call__.__getattr__系列.__get ...
- Oracle PL/SQL入门之慨述
Oracle PL/SQL入门之慨述 一.PL/SQL出现的目的 结构化查询语言(Structured Query Language,简称SQL)是用来访问关系型数据库一种通用语言,它属于第四代语言( ...
- PHP 让__get方法重新执行
<?php class A { public function __get($p) { echo "getting $p\r\n"; if(isset($this->$ ...
- Debian 安装Linux源码
参考: http://blog.chinaunix.net/uid-20683355-id-1895778.html http://www.linuxdiyf.com/viewarticle.php? ...
- ResourceBundle (读取properties文件及中文乱码解决方法)
原文:http://blog.csdn.net/joecheungdishuiya/article/details/6304993 public class test { static Resourc ...