java中文乱码解决方案
一.tomcat-6.0/apache-tomcat-6.0.18/conf/server.xml
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" URIEncoding="utf-8" /> 這個(gè)很重要 貌似第一次就是這個(gè)問題
二.struts 2.1.6 的 org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter??
有bug,所以亂碼
換 org.apache.struts2.dispatcher.FilterDispatcher??
或用
spring的?org.springframework.web.filter.CharacterEncodingFilter?解決??
基本思路:
1.JSP 頭部contentType用 UTF-8
2.tomcat配置里面 URIEncoding="UTF-8"
3.處理得Servlet里面設(shè)置編碼 UTF-8 (Action還是servlet隨便,反正應(yīng)該有個(gè)總控得)
4.數(shù)據(jù)庫 UTF-8
5.過濾器(如果你寫了,我從沒寫過要配置到xml里面得filter) UTF-8
6.其他任何需要設(shè)置編碼得地方 UTF-8
轉(zhuǎn)載于:https://www.cnblogs.com/jerome-rong/archive/2012/05/09/2492179.html
總結(jié)
以上是生活随笔為你收集整理的java中文乱码解决方案的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。