window.location.href=传值的中文乱码解决方法


jsp:

encodeURI() 函数可把字符串作为 URI 进行编码。

var goodname=$("#select").val();

window.location.href="goodAction_select.action?good.goodname="+encodeURI(encodeURI(goodname));
    alert(goodname);

action:

UrlDecode是对字符串进行URL解码的编码处理函数。 通过urlencode编码后的字符串,可通过UrlDecode进行解码

String str =  URLDecoder.decode(this.good.getGoodname(), "UTF-8");
goodslist=goodsService.getGoodsByName(str);

猜你喜欢

转载自blog.csdn.net/heiiochange/article/details/78131456