以下是關鍵語句,注意轉碼的先后順序,這源于GET是HTTP服務器處理,而POST是WEB容器處理:
String name = request.getParameter("nameGet");name = new String(name.getBytes("ISO-8859-1"), "gb2312");
================================
request.setCharacterEncoding("gb2312");
String name = request.getParameter("namePost");
(轉)
在TOMCAT中,GET請求的編碼可以通過設置Connector來指定編碼,默認設定為ISO8859-1
新聞熱點
疑難解答