zoukankan      html  css  js  c++  java
  • 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>

  • 相关阅读:
    bootstrap学习笔记
    java-多态
    java-重写
    java-继承
    java-包
    java-封装
    java-可变参数
    java-标准输入
    java-构造方法
    private、public、this关键字
  • 原文地址:https://www.cnblogs.com/xkoko/p/10443525.html
Copyright © 2011-2022 走看看