1. 程式人生 > >SpringMVC如何解決POST請求中文亂碼問題,GET的又如何處理呢?

SpringMVC如何解決POST請求中文亂碼問題,GET的又如何處理呢?

rec ppi utf-8 proto style app 亂碼問題 ping 解決

在web.xml中

<filter>
    <filter-name>CharacterEncodingFilter</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> <filter-mapping> <filter-name>CharacterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
以上可以解決post請求亂碼問題。 對於get請求中文參數出現亂碼解決:修改tomcat配置文件添加編碼與工程編碼一致,如下:
<Connector   URIEncoding
="utf-8" connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>

SpringMVC如何解決POST請求中文亂碼問題,GET的又如何處理呢?