处理springMvc中responsebody返回中文乱码

JAVA学习网 2018-01-26 20:47:06

法一:

 1 @RequestMapping(value="/getUsersByPage",produces = "application/json; charset=utf-8") 2 @ResponseBody 3 public String getUsers 

法二:在spring-mvc.xml中配置

 1     <mvc:annotation-driven>
 2         <mvc:message-converters>
 3             <bean class="org.springframework.http.converter.StringHttpMessageConverter">
 4                 <property name="supportedMediaTypes">
 5                     <list>
 6                         <value>application/json;charset=UTF-8</value>
 7                     </list>
 8                 </property>
 9             </bean>
10         </mvc:message-converters>
11     </mvc:annotation-driven>

 

阅读(710) 评论(0)