java json数据返回值中文乱码 出现???


 

后台方法返回值出现乱码

 

JSONObject json=new JSONObject();

json.put("totals1",map);

 return json.toJSONString();

 

如图

 

 解决办法:在Spring-MVC.xml配置文件添加以下配置,然后直接返回要生成Json串的对象 

<mvc:annotation-driven>
<mvc:message-converters register-defaults="true">
<bean id="stringHttpMessageConverter" class="org.springframework.http.converter.StringHttpMessageConverter">
<property name="supportedMediaTypes" value="application/json;charset=UTF-8"/>
</bean>
</mvc:message-converters>
</mvc:annotation-driven>

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM