1.首先要確保web工程的配置文件web.xml中對EncodingFilter進行了相應的設置,編碼與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> <init-param> <param-name>forceEncoding</param-name> <param-value>true</param-value> </init-param> </filter> <filter-mapping> <filter-name>encodingFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>
2.很多情況下,第一種情況無法達到目的。接下來修改 jetty_home/lib/jetty-webapp-8.1.4.v20120524.jar中webdefault.xml,把zh所指向的編碼更改為UTF-8,保存更新就行了。
<locale-encoding-mapping>
<locale>zh</locale>
<encoding>UTF-8</encoding>
<locale-encoding-mapping>