JSP页面多form下的hidden域传值异常解决方案

在毕业设计过程中,发现JSP页面中存在多个form时,form中通过hidden(隐藏域)提交的数据有时候会出现找不到的现象。为了解决这个问题想了很多办法,最后通过以下方法解决的。

直接将所需传递的参数以Url的形式传递

1. a.jsp

在a页面中,通过如下代码将Url放入request中

 

<form ... > ... <input type="hidden" name="preUrl" value="mgritem.do?status=list"> ... </form>

 

2. Action/Form中

 

request.setAttribute("preUrl", request.getParameter("preUrl"));

 

3. b.jsp

在b页面中,从request中取出Url

 

<logic:present name="preUrl" scope="request"> 	<a href=${preUrl} target="_self"><img src="../../images/bt7.gif" border="0" alt="返回至上一页"></a> </logic:present> <logic:notPresent name="preUrl" scope="request"> 	<a href=javascript:window.location.href=document.referrer><img src="../../images/bt7.gif" border="0" alt="返回上一页"> </a> </logic:notPresent>

你可能感兴趣的:(JavaScript,jsp)