URL参数中文乱码解决(参数中间经过两次使用)

在配合CRM做二期项目时,在网点查询功能实现的时候,由于使用的get方式传递中文参数,导致新打开的jsp 获取参数为乱码。
URL中contactAddr,shopSite均为中文参数
var url = path+"/service/depponDept/depponDept_search_visitframe.jsp?custAddress="
+ encodeURI(encodeURI(contactAddr)) + "&shopSite=" + encodeURI(encodeURI(shopSite));


jsp上获取参数Java代码
String custAddress = StringUtil.killNull(request.getParameter("custAddress"));
String shopSite = StringUtil.killNull(request.getParameter("shopSite"));
custAddress=URLDecoder.decode(custAddress,"UTF-8");
shopSite = URLDecoder.decode(shopSite,"UTF-8");

但是这两个参数还要第二次在URL中使用:
<frame name="top" scrolling="no" noresize src="<%=path%>/service/depponDept/depponDept_visitSearch.jsp?custAddress=<%=URLEncoder.encode(URLEncoder.encode(custAddress,"UTF-8"),"UTF-8")%>&shopSite=<%=URLEncoder.encode(URLEncoder.encode(shopSite,"UTF-8"),"UTF-8")%>">

最终使用URL中的这两个参数处理代码为:
String custAddress = StringUtil.killNull(request.getParameter("custAddress"));
String shopSite = StringUtil.killNull(request.getParameter("shopSite"));
custAddress=URLDecoder.decode(custAddress,"UTF-8");
shopSite=URLDecoder.decode(shopSite,"UTF-8"
);

这就是URL中文参数两次处理过程。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值