我有一种情况,我需要更新名称保持不变的setAttribute的值。以下面的情况为例 -
假设我有三个JSP:abc.jsp,xyz.jsp,pqr.jsp。现在开始abc.jsp运行,然后控制转发到xyz.jsp &然后转发到pqr.jsp。在执行pqr.jspthe后,再次使用setAttribute处的更新值重新执行xyz.jsp。
abc.jsp:
如何更新session.setAttribute(name,value)值,其中名称相同?
ArrayList<Books> getSupplyStatus=new ArrayList<Books>();
JavaBean javaBean=new JavaBean();
session=request.getSession(false);
getSupplyStatus=javaBean.getSupplyStatus(memberID); //It returns a ArrayList
if(!getSupplyStatus.isEmpty())
{
session.setAttribute("UpdatedBooklist", getSupplyStatus);
request.getRequestDispatcher("xyz.jsp").forward(request, response);
}
xyz.jsp:
session=request.getSession(false);
ArrayList<Books> getSupplyStatus=(ArrayList<Books>) session.getAttribute("UpdatedBooklist");
// some operations & forward to pqr.jsp
pqr.jsp:
// in this jsp new ArrayList<Books> will be prodeuced
// & I need to bound the value of "UpdatedBooklist" with
// which is set in abc.jsp,
// and previous value must be override & then forward to xyz.jsp again
// In xyz.jsp we recieve the updated value.
请澄清你的问题更多。 – 2013-04-10 05:41:40