2017.6.17 jsp中 get請求的中文亂碼問題的解決方法
阿新 • • 發佈:2017-06-17
utf meta class enc 請求 服務 charset url編碼 uri
一般Tocant 的url編碼是iso-8859-1(查看tocat/conf/server.xml 中的Connector 節點沒有寫URIEncoding="xxxxxx") 如下:
<Connector port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
最後我這個問題是這麽解決:
(1)Tomcat中server.xml中,紅色為新加設置
<Connector URIEncoding="UTF-8" port="8080" protocol="HTTP/1.1" connectionTimeout="20000" redirectPort="8443" />
(2)服務器代碼處理編碼設置
response.setCharacterEncoding("UTF-8");
(3)html頁面
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
2017.6.17 jsp中 get請求的中文亂碼問題的解決方法