request.getParameter() 中文亂碼
問題原因
Http請求傳輸時將url以ISO-8859-1編碼,服務器收到字節流後默認會以ISO-8859-1編碼來解碼成字符流(造成中文亂碼)
解決方法
String str = new String(request.getParameter("param").getBytes("iso-8859-1"), "utf-8");
Http請求傳輸時將url以ISO-8859-1編碼,服務器收到字節流後默認會以ISO-8859-1編碼來解碼成字符流(造成中文亂碼)
String str = new String(request.getParameter("param").getBytes("iso-8859-1"), "utf-8");