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