java之亂碼

java常見亂碼

1.request.getCharacterEncoding("utf-8");

2.new String(username.getBytes("iso-8859-1","utf-8"))

3.tomcat默認情況下只適合post傳值

在server.xml中找到Connector標籤 添加一個屬性useBodyEncodingForUrl="true"或者URIEncoding="utf-8";

4.數據庫與表設置



5.響應亂碼

response.setContextType("text/html");

response.setCharacterEncoding("utf-8");

6.連接字符串編碼設置

jdbc:mysql://localhost:3306/album?characterEncoding=utf-8

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