quhaojian 2015-11-18 07:47 采纳率: 50%
浏览 2889
已采纳

spring mvc json返回中文乱码 配置后依然不好使

  <context:annotation-config />
     <context:component-scan base-package="may.web.action"></context:component-scan>


      <bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
                <property name="messageConverters">
                    <list>
                         <bean class = "org.springframework.http.converter.StringHttpMessageConverter">    
                  <property name = "supportedMediaTypes">   
                        <list>    
                          <value>text/plain;charset=UTF-8</value>
                          <value>application/json;charset=UTF-8</value>    
                      </list>    
                  </property>  
                     </bean> 
                     <bean  class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />
                  </list>
            </property>
            <property name="webBindingInitializer">  
                <bean class="may.filter.MyBindingInitializer"/>  
            </property>
         </bean> 

     <bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver" >
        <property name="viewClass"
                    value="org.springframework.web.servlet.view.JstlView" />
        <property name="prefix" value="/jsp/"></property>  
        <property name="suffix" value=".jsp"></property>  
        </bean>
    <mvc:annotation-driven/>


      </beans>
        xml已经配置了  但是还是中文乱码  还是text/plain:charset=ISO8859-1,自己弄了一下午 但还是不好使 
  • 写回答

3条回答 默认 最新

  • CS568591377 2015-11-18 08:30
    关注
        <!-- mvc 返回乱码处理 -->
        <mvc:annotation-driven>
            <mvc:message-converters register-defaults="true">
                <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                    <property name="supportedMediaTypes" value="text/plain;charset=UTF-8" />
                </bean>
            </mvc:message-converters>
        </mvc:annotation-driven>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 优质github账号直接兑换rmb,感兴趣伙伴可以私信
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊
  • ¥15 安装svn网络有问题怎么办
  • ¥15 Python爬取指定微博话题下的内容,保存为txt
  • ¥15 vue2登录调用后端接口如何实现
  • ¥65 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)