读书人

javascript url 传递参数中文乱码有关

发布时间: 2012-11-23 22:54:33 作者: rapoo

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 简单明了,实用

读书人网 >JavaScript

热点推荐