spring mvc解决返回json乱码的问题
2017-12-19 11:18
411 查看
自己搭建了一个spring mvc的框架,第一次返回json乱码
在response中设置编码格式为utf-8均宣告失败,因为response默认返回的是iso-8859-1
最后在sping.xml中增加配置信息
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean>
解决了返回json乱码的问题
该段信息最好在
<!-- 搜索spring控件 -->
<context:component-scan base-package="hlx"></context:component-scan>之上
在response中设置编码格式为utf-8均宣告失败,因为response默认返回的是iso-8859-1
最后在sping.xml中增加配置信息
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter">
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.json.MappingJackson2HttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/html;charset=UTF-8</value>
<value>application/json;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean>
解决了返回json乱码的问题
该段信息最好在
<!-- 搜索spring控件 -->
<context:component-scan base-package="hlx"></context:component-scan>之上
相关文章推荐
- spring mvc json 返回乱码问题解决(vestion:3.x.x)
- spring mvc json 返回乱码问题解决(vestion:3.x.x)
- Spring MVC后台返回JSON数据中文乱码问题解决
- Spring MVC3返回JSON数据中文乱码问题解决
- Spring mvc 使用Gson 返回Json数据 中文乱码问题
- httpurlconnection post 和GET 分别传递2个参数给后台,返回JSON 解决乱码问题
- 详解Spring MVC3返回JSON数据中文乱码问题解决
- springMvc框架解决返回Json格式中文乱码问题
- 解决服务器返回JSON数据中文乱码问题
- JavaScript传中文值给Action出现乱码问题解决和返回ajax 返回 输出 json 乱码
- SpringMVC返回JSON乱码问题解决办法
- Spring MVC使用@ResponseBody返回JSON数据406以及乱码问题解决方案
- spring解决后台json返回乱码问题
- Spring MVC3返回JSON数据中文乱码问题解决(转)
- 解决spring-mvc @responseBody注解返回json 乱码问题
- 解决springmvc返回json数据IE出现文件下载和json数据中文乱码问题
- Django学习问题——解决返回JSON数据时中文出现乱码
- springmvc解决ajax返回json数据乱码问题
- spring boot 解决后台返回 json 到前台出现中文乱码的问题
- cxf web service 解决返回的json格式数据乱码问题