java 中解決中文亂碼問題的方法

1. 重新定義。 String str = "衝蟲蟲" ; str = new String(u.getBytes("iso-8859-1"),"utf-8");

2. 使用過濾器解決。

3. 修改Tomcat配置server.xml,

 <Connector port="80" protocol="HTTP/1.1"               connectionTimeout="20000"                redirectPort="8443"  />改爲:

 <Connector port="80" protocol="HTTP/1.1"                connectionTimeout="20000"  URIEconding="UTF-8"            redirectPort="8443"  />

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章