jsp页面:跳转 A.jsp 页面 参数编码:
encodeURIComponent(encodeURIComponent(JSON.stringify(data),"UTF-8"),"UTF-8")
<div id="cirInfoExportInfoPage">
</div>
var toPageFormUrl =contextPath+"/A.jsp";
var exportInfoFormHtml="<form id=\"toPageForm\" method=\"post\" name=\"toPageForm\" action=\""+toPageFormUrl+"\" target=\"_blank\">";
exportInfoFormHtml+="<input type=\"hidden\" name=\"exportInfoData\" id=\"exportInfoData\" value=\""+encodeURIComponent(encodeURIComponent(JSON.stringify(data),"UTF-8"),"UTF-8")+"\"/>";
exportInfoFormHtml+="</form>";
$('#cirInfoExportInfoPage').html(exportInfoFormHtml);
$("#toPageForm").submit();
A.jsp页面:接收参数对应解码:decodeURIComponent(decodeURIComponent(_exportInfoData,"UTF-8"),"UTF-8")
然后 str 转 json :_exportInfoData =JSON.parse(_exportInfoData);
<%String exportInfoData = request.getParameter("exportInfoData")==null?"":request.getParameter("exportInfoData").toString();%>
<script>
var _exportInfoData="<%=exportInfoData%>";
_exportInfoData = decodeURIComponent(decodeURIComponent(_exportInfoData,"UTF-8"),"UTF-8");
_exportInfoData =JSON.parse(_exportInfoData);
</script>
本文介绍如何在JSP页面之间传递参数,使用encodeURIComponent进行编码,并在目标页面A.jsp通过decodeURIComponent解码,将JSON字符串转换为对象。
7637

被折叠的 条评论
为什么被折叠?



