Web端亂碼處理的幾種方式

亂碼處理:

1Jsp頁面上的編碼方式統一改爲“utf-8

2ServaltdoPosedoGet中寫上:

Request.setCharacterEncoding(“utf-8”);

Response.setContentType(“test/html;charset=utf-8”);

3、對於get方式提交到Servlet的數據:

String username =

                   Request.getParameter(“username”);

New String (username.getBytes(“IOS-8859-1”),“utf-8”);

4.jdbc鏈接後加上

?useUnicode=true&charcaterEncoding=utf-8

示列:

“jdbc:mysql://loucalhost:3306/表名?useUnicode=true&characterEncoding=utf-8”;

5、在tomate的安裝目錄的/conf/server.xml文件中找到Connector,加上URIEncoding=utf-8”;

<Connector

Port=”8080”

Connection Timeout=”20000”

disableUploadTimeout=”true”

URIEncoding=”utf/8”/>

不推薦只用第五種,弄錯了MySql就需要重裝


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