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>

原文地址:https://www.cnblogs.com/xkoko/p/10443525.html