解決webwork utf-8 亂碼問題
起因:使用webwork+spring開發,出現提交數據亂碼。
1,首先嘗試修改webwork配制文件webwork.properties
webwork.locale=zh_CN
webwork.i18n.encoding=UTF-8
沒有解決問題
2,再次嘗試加入filter
?<filter>
??<filter-name>SetCharacterEncoding</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>SetCharacterEncoding</filter-name>
??<url-pattern>*.jsp</url-pattern>
?</filter-mapping>
?<filter-mapping>
??<filter-name>SetCharacterEncoding</filter-name>
??<url-pattern>*.action</url-pattern>
?</filter-mapping>
還是沒有解決問題。
3,嘗試更改提交方式 ,頁面上加上? method="post"
問題解決。但是新問題出現,url中出現的中文依然是亂碼
更改tomcat server.xml文件,在<Connector port="8080" >中加入URIEncoding="utf-8"問題解決,
但有更好的一種解決方案。就是用useBodyEncodingForURI="true"代替URIEncoding="utf-8"
這樣tomcat會根據頁面的編碼去處理
大盤預測
國富論
posted on 2008-01-13 14:49
華夢行 閱讀(357)
評論(0) 編輯 收藏