1. 简介

主要解决@ResponseBody注解返回的json中文乱码问题。

2.解决方案

2.1mvc加上注解(推荐此方法)

在mvc配置文件中假如下面配置(写在 <mvc:annotation-driven/>之前才有效)



<bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" >
    <property name="messageConverters">
        <list>
            <bean class="org.springframework.http.converter.StringHttpMessageConverter">
                <property name="supportedMediaTypes">
                    <list>
                        <value>text/plain;charset=utf-8</value>
                        <value>text/html;charset=UTF-8</value>
                    </list>
                </property>
            </bean>
        </list>
    </property>
</bean>

2.2 使用@RequestMapping注解的produces方法

@RequestMapping(value = "testPersonalValidtor.do",produces = "application/json;charset=utf-8")

相关文章:

  • 2021-05-26
  • 2021-09-09
  • 2022-12-23
  • 2021-06-09
  • 2021-07-18
  • 2022-12-23
  • 2021-08-23
猜你喜欢
  • 2022-12-23
  • 2022-03-01
  • 2021-08-08
  • 2022-12-23
  • 2021-12-10
  • 2022-12-23
相关资源
相似解决方案