需求:
从A.jsp 传值到B.jsp。
A页面标签:
<!-- 用户扣款协议跳转页面 --> <form action="b.jsp" target="_blank" method="post"> <input type="hidden" name="nameForm" value=""/> <input type="hidden" name="credentialsNoForm" value=""/> <input type="hidden" name="uNameForm" value=""/> <input type="hidden" name="currentDateForm" value=""/> <input type="hidden" name="bankCardNoForm" value=""/> <input type="hidden" name="bankNameForm" value=""/> <input type="hidden" name="amountForm" value=""/> <input type="submit" value="提交" id="agreementFormBtn"/> </form>
A页面js:
$("#agreementFormBtn").click(function(){ var today=new Date(); var year=today.getFullYear(); var month=today.getMonth()+1; var day=today.getDate(); var currentDate=year+"年"+month+"月"+day+"日"; $("input[name=currentDateForm]").val(currentDate); $("input[name=nameForm]").val(name); $("input[name=credentialsNoForm]").val(credentialsNo); $("input[name=bankCardNoForm]").val(bankCardNo); $("input[name=amountForm]").val(amount); $("input[name=bankNameForm]").val(bankName); $("input[name=uNameForm]").val($(".user-name").text()); });
B页面取值:
<ul class="step1"> <li><strong>授权人</strong></li> <li>姓名:<%=request.getParameter("nameForm")%></li> <li>证件类型:身份证</li> <li>证件号码:<%=request.getParameter("credentialsNoForm")%></li> <li>好贷宝用户名:<%=request.getParameter("uNameForm")%></li> <li>日期:<%=request.getParameter("currentDateForm")%></li> </ul>