我有一種情況,我需要更新名稱保持不變的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