日期:2014-05-18  浏览次数:20947 次

紧急求助一个关于传递中文参数的问题!!!!!!!!!!!!!!!!!
title= "CSDN_专家门诊 "
使用如下方式传递参数:
http://localhost/post1.jsp?t=escape(title)
我用request.getQueryString()得到的是:
t=CSDN_%u4E13%u5BB6%u95E8%u8BCA
而我用request.getParameter( "t ")得到的是null;
请教该如何处理才能得到 "CSDN_专家门诊 "这字符串


------解决方案--------------------
Encoder and Decoder
------解决方案--------------------
过是通过GET方法传递的参数如:url ../test.jsp?v=汉字
的话 应该把汉字转化成 UTF-8的编码在传过去[URLEncoder.encode( "汉字 ", "GB2312 ")]
取的时候在转化回来[URLDEcoder.decode( "汉字 ", "GB2312 ")
如果是tomcat的话 在server.xml 的
<Connector
port= "8080 "
中加入
URIEncoding= "GB2312 "
最好在写个 过滤器

------解决方案--------------------
在server.xml的connector加上URIEncoding= "gbk "
如:
<Connector port= "8080 " maxHttpHeaderSize= "8192 "
maxThreads= "1000 " minSpareThreads= "256 " maxSpareThreads= "512 "
enableLookups= "false " redirectPort= "8443 " acceptCount= "512 "
connectionTimeout= "20000 " disableUploadTimeout= "true " URIEncoding= "gbk "/>

页面
<%@ page contentType= "text/html; charset=gbk " %>
<%
request.setCharacterEncoding( "GBK ");
String str = request.getParmameter( "t ");
out.println(t);
%>
------解决方案--------------------
页面1:

<body>

<a href= "chTest.jsp?t= 'CSDN_专家门诊 ' "> 中文参数 </a>
</body>

页面2:
<body>
<%
request.setCharacterEncoding( "GBK ");
String s=request.getParameter( "t ");
s=new String(s.getBytes( "ISO8859-1 "), "GBK ");
out.print(s);
%>
中文的页面 <br>
</body>