在链接中有中文参数取出会乱码,下面是一种解决方法:
1、js转码
var tag=document.getElementById("shopname").value;
tag=encodeURI(encodeURI(tag));
document.location=view.do?method=viewShop&tag="+tag;
2、在action中解码
String tag = request.getParameter("tag").toString();
tag = java.net.URLDecoder.decode(tag,"UTF-8");
http://www.gaodaima.com/29612.html
——————————-另一种方法—————————————–
1、js转码
var tag=document.getElementById("shopname").value;
tag=encodeURI(tag);
document.location=view.do?method=viewShop&tag="+tag;
2、在action中解码
String tag = request.getParameter("tag").toString();
tag = new String(tag.getBytes("ISO8859-1"),
"UTF-8");
这种你的程序代码需要为UTF-8编码
欢迎大家阅读《js 链接中文乱码_js》,跪求各位点评,若觉得好的话请收藏本文,by 搞代码