解決post請求亂碼問題
方式一:
//編碼
// String encodeUsername = URLEncoder.encode(username, "iso-8859-1");
//解碼
// username = URLDecoder.decode(encodeUsername, "utf-8");
//方式二:
//編碼
// byte[] bytes = username.getBytes("iso-8859-1");
//解碼
// username = new String(bytes, "utf-8");
//方式二變為一行代碼
username = new String(username.getBytes("iso-8859-1"), "utf-8");
注意:以上
最終版:
1.解決post請求中文亂碼問題
request.setCharacterEncoding("utf-8");
2.解決服務器response給瀏覽器時的亂碼問題
response.setContentType("text/html;charset=utf-8");

浙公網安備 33010602011771號