springMVC值傳入後臺就亂碼問題解決

一、當你使用以下方法web

<filter>  
<filter-name>encodingFilter</filter-name>  
<filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>  
<init-param>  
<param-name>encoding</param-name>  
<param-value>UTF-8</param-value>  
</init-param>  
</filter>

二、或者修改tomcat的配置文件:server.xmlspring

<Connector connectionTimeout="20000" port="8088" protocol="HTTP/1.1" redirectPort="8443" <span style="color:#FF6666;">URIEncoding="UTF-8"</span>/>

都沒有用的時候能夠嘗試這樣tomcat

new String(str.getBytes("iso-8859-1"), "UTF-8")

經過強行轉換。 str:是你傳遞的參數spa

相關文章
相關標籤/搜索