(1)確定JSP頁(yè)面頭部是否有:<%@ page contentType="text/html; charset=GBK" %>
(2)用這個(gè)轉(zhuǎn)碼:
???? String param= new String(request.getParameter("param").getBytes("ISO-8859-1"), "GBK");
(3)添加filter字符過濾器
(4)如果是通過"a.jsp?param=中文"傳遞參數(shù),則需要:
???? a.在傳參數(shù)之前先把參數(shù)進(jìn)行轉(zhuǎn)碼:java.net.URLEncoder.encode(param);
?????? 取值用java.net.URLDncoder.decode(param);再轉(zhuǎn)回中文
???? b.在你的Tomcat目錄-->conf目錄-->server.xml里找出這段:
?????? <Connector
???????? port="8080"?????????????? maxThreads="150" minSpareThreads="25" maxSpareThreads="75"
?????????????? enableLookups="false" redirectPort="8443" acceptCount="100"
?????????????? debug="0" connectionTimeout="20000"
?????????????? disableUploadTimeout="true" <!--在里邊加上這個(gè)參數(shù)-->URIEncoding="gb2312"/>
from: http://www.yuanma.org/data/2006/0911/article_1503.htm