Spring mvc返回json乱码解决方式
2017-03-29 12:29
423 查看
在spring-mvc.xml配置文件中添加
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean
class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<bean class="org.springframework.http.MediaType">
<constructor-arg index="0" value="text" />
<constructor-arg index="1" value="plain" />
<constructor-arg index="2" value="UTF-8" />
</bean>
</list>
</property>
</bean>
</list>
</property>
</bean>
注意:上面的配置应该写在controller的扫描配置之前
<bean
class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="messageConverters">
<list>
<bean
class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<bean class="org.springframework.http.MediaType">
<constructor-arg index="0" value="text" />
<constructor-arg index="1" value="plain" />
<constructor-arg index="2" value="UTF-8" />
</bean>
</list>
</property>
</bean>
</list>
</property>
</bean>
注意:上面的配置应该写在controller的扫描配置之前
相关文章推荐
- Spring MVC 对于返回JSON格式数据的中文乱码 解决方法
- Springboot使用FastJson后,接口返回中文乱码的问题解决(两种解决方式)
- Spring MVC后台返回JSON数据中文乱码问题解决
- spring mvc json 返回乱码问题解决(vestion:3.x.x)
- SpringMVC Ajax返回的请求json 的方式来解决在中国字符串乱码问题
- spring mvc解决返回json乱码的问题
- spring mvc json 返回乱码问题解决(vestion:3.x.x)
- spring mvc 中通过responsebody返回json格式到jsp页面乱码解决方法
- SpringMVC3的ResponseBody返回字符串(JSON)乱码问题解决
- Json返回时间中出现乱码问题的两种解决方法
- [Spring MVC] @ResponseBody返回结果乱码问题的解决
- spring 返回 JSON乱码问题的解决 及个人 动态加载ztree树结构的json数据代码
- Json返回时间中出现乱码问题的两种解决方法
- Spring MVC3返回JSON数据中文乱码问题解决
- Spring MVC使用fastjson数据传到前台中文乱码解决
- [原][Spring MVC] @ResponseBody返回结果乱码问题的解决
- Spring mvc 返回Json乱码;
- 腾讯微博api 解决中文乱码及解析返回的json数据
- SpringMVC3的ResponseBody返回字符串(JSON)乱码问题解决
- 解决服务器返回JSON数据中文乱码问题