session超时后跳转的问题?
过期时能在HttpSessionListener的sessionDestroyed方法中可以得到mangerLevelpublic void sessionDestroyed(HttpSessionEvent se) {
HttpSession session = se.getSession();
LoginForm loginForm=(LoginForm)session.getAttribute("loginForm");
System.out.println(loginForm.getManagerLevel()); //打印出9
session.setAttribute("mlFlag", loginForm.getManagerLevel());
}
当点击包含".do"的请求时怎么才能到Filter中的request.gerSession中获得“mlFlag”
if (url.indexOf(".do") >= 0 )
{
HttpSession session = ((HttpServletRequest) request).getSession(true);
if (session.getAttribute("loginForm") == null)
{
String managerLevel = (String)session.getAttribute("mlFlag");
System.out.println(managerLevel + "------------------"); //总为null,怎样在这里获得sessionDestroyed方法中设置的“mlFlag”的值?
if ( "9".equals(managerLevel)){
hrep.sendRedirect(hreq.getContextPath() + "/timeout.jsp?managerLevelFlag=" + managerLevel);
}else {
hrep.sendRedirect(hreq.getContextPath() + "/timeout.jsp?managerLevelFlag=-1");
}
}
else
{
chain.doFilter(request, response);
}
}
可能本人对Filter,Listener相结合操作没理解好,要实现这种功能有什么好方法?
谢谢各位!