spring mvc rest风格的URL输入中文乱码问题

来源:互联网 发布:2017流行网络歌曲500首 编辑:程序博客网 时间:2024/06/05 20:54

 

<!-- 处理请求时返回json字符串的中文乱码问题 --><mvc:annotation-driven><mvc:message-converters><bean class="org.springframework.http.converter.StringHttpMessageConverter"><property name="supportedMediaTypes"><list><value>text/html;charset=UTF-8</value></list></property></bean></mvc:message-converters></mvc:annotation-driven>

 

tomcat 的 server.xml中,加入URIEncoding="UTF-8"

<Connector port="8080" URIEncoding="UTF-8" protocol="HTTP/1.1"               connectionTimeout="20000"               redirectPort="8443" />

 

当然,也可以在代码里转

new String(s1.getBytes("ISO-8859-1"), "UTF-8");

 

 

 

原创粉丝点击