jsp页面间传递参数 中文乱码问题(zz)
时间:2014-10-10 10:44:24
收藏:0
阅读:175
jsp页面间传递参数 中文乱码问题
window.location="Test.jsp?param1="+encodeURI(encodeURI(str));//对中文参数进行双层编码后再传递
URLDecoder.decode(request.getParameter("param1"),"utf-8");//对中文参数进行解码
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
url="xxx.jsp?id="+java.net.URLEncoder.encode("中文", "UTF-8") //加码
接收时,我们用
String inf=request.getParameter("id");
inf= new String(inf.getBytes("iso-8859-1"),"UTF-8"); 解码
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
评论(0)