1. 簡介
主要解決@ResponseBody注解返回的json中文亂碼問題。
2.解決方案
2.1mvc加上注解(推薦此方法)
在mvc配置文件中假如下面配置(寫在 <mvc:annotation-driven/>之前才有效)
<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" >
<property name="messageConverters">
<list>
<bean class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes">
<list>
<value>text/plain;charset=utf-8</value>
<value>text/html;charset=UTF-8</value>
</list>
</property>
</bean>
</list>
</property>
</bean>
2.2 使用@RequestMapping注解的produces方法
@RequestMapping(value = "testPersonalValidtor.do",produces = "application/json;charset=utf-8")