我在一个filter的doFilter方法中存入一个session值
- Java code
HttpServletRequest httpRequest = (HttpServletRequest) request;httpRequest.getSession().setAttribute("login", account);chain.doFilter(httpRequest, httpResponse);
在servlet中是可以取得到的
- Java code
public void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {String userAccount = request.getParameter("userAccount"); respons.setContentType("text/html; charset=UTF-8"); try { out = respons.getWriter(); } catch (IOException e) { e.printStackTrace(); } //注销session HttpSession session = request.getSession(); }
但是为什么我在另外一个filter中取不到这个login的值
- Java code
HttpServletRequest httpRequest = (HttpServletRequest)request;Object login = httpRequest.getSession().getAttribute("login");
应该怎么取?求高手指点
------解决方案--------------------
先后顺序惹的祸