在配合CRM做二期项目时,在网点查询功能实现的时候,由于使用的get方式传递中文参数,导致新打开的jsp 获取参数为乱码。
jsp上获取参数Java代码
但是这两个参数还要第二次在URL中使用:
最终使用URL中的这两个参数处理代码为:
这就是URL中文参数两次处理过程。
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中文参数两次处理过程。