js window.open将参数传递到struts中出现的乱码问题解决

在页面的时候首先要对传递到后台的参数进行编码一些

path=encodeURI(encodeURI(path));

fileName=encodeURI(encodeURI(fileName));

注意如果使用一个encodeURI()的话在后台接收到的就是????号写两个就是%4%3%3这种的

window.open(url+"?path="+path+"?fileName="+fileName);

到后台接受参数后

String path=ServletActionContext.getRequest().getParameter("path").toString();
  String fileName=ServletActionContext.getRequest().getParameter("fileName").toString();
 

在次进行转码:

  path=java.net.URLDecoder.decode(path,"UTF-8");
  fileName=java.net.URLDecoder.decode(fileName,"UTF-8");

现在就没有乱码了!

转载于:https://my.oschina.net/luotao/blog/112747

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值