处理springMvc中responsebody返回中文乱码

法一:

 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>

 

posted @ 2018-01-26 14:34  夜旦  阅读(218)  评论(0编辑  收藏  举报