日期:2014-05-16  浏览次数:20326 次

javascript url 传递参数中文乱码问题解决方案
html页面:

function testOne() {

   var url = "testTwo.action?expr="+你好;

    window.location.href = encodeURI(url);

}


后台java代码:

String expr = new String(request.getParameter("expr").getBytes("ISO-8859-1"),"UTF-8"); 


方案二

html页面:

function testTwo() {

var url = "testTwo.action?expr="+你好;

   window.location.href= encodeURI(encodeURI(url));

}


后台java代码:

String expr = java.net.URLDecoder.decode(lrequest.getParameter("expr") , "UTF-8");
1 楼 janwen 2010-12-24  
简单明了,实用