標籤:background spring border 攔截器 style
今天開發的時候遇到這個問題,記性差,記下來先。
1、設定web.xml,添加utf-8攔截器
<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> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>characterEncodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> |
2、修改tomcat設定檔。
修改apache-tomcat-XXX\conf\server.xml檔案,在<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8453"/>後面添加useBodyEncodingForURI="true" URIEncoding="UTF-8"。添加後如下:
<Connector connectionTimeout="20000" port="8080" protocol="HTTP/1.1" redirectPort="8443" useBodyEncodingForURI="true" URIEncoding="UTF-8"/> |
spring mvc通過jQuery ajax傳值中文亂碼問題