@ResponseBody注解使用返回类型为String时出现中文乱码

来源:互联网 发布:js 屏幕手写板 编辑:程序博客网 时间:2024/06/08 16:17

在spring-mvc配置文件中添加:


<!-- @ResponseBody utf-8曲编码 --><bean class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" >    <property name="messageConverters">        <list>            <bean class="org.springframework.http.converter.json.MappingJacksonHttpMessageConverter" />            <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>

这只是其中一种方式,个人适用,如果不行,请另行百度其他解决方案,各位大神提供的比较全面,就不再赘述了。

阅读全文
0 0