当前位置: 代码迷 >> J2EE >> filter 取session值有关问题
  详细解决方案

filter 取session值有关问题

热度:28   发布时间:2016-04-22 01:59:02.0
filter 取session值问题
我在一个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");

应该怎么取?求高手指点

------解决方案--------------------
先后顺序惹的祸
  相关解决方案