请检查这个问题的答案,我找到了这个问题:enter link description here
我怎么能用会话做到这一点:
request.setAttribute("attributeName",yourStringVAlue);
RequestDispatcher rd = request.getRequestDispatcher("yourServletPattern");
rd.forward(request,response);
并检索:
String someName = (String)request.getAttribute("attributeName");
答案 0 :(得分:3)
你说“使用会话”。
设置变量:
HttpSession session = request.getSession();
session.setAttribute("myId","myVariable");
检索变量:
HttpSession session = request.getSession();
String var = (String) session.getAttribute("myId");