public void doFilter(ServletRequest req, ServletResponse res,
FilterChain chin) throws IOException, ServletException {
String errors = "errors.jsp";
HttpServletRequest hreq =(HttpServletRequest)req;
HttpServletResponse hres = (HttpServletResponse)res;
isLOG = (String) hreq.getSession().getAttribute("LOG");
if(isLOG!=null&&(isLOG.equals("true")||isLOG=="true")){
chin.doFilter(req,res);
hreq.getSession().removeAttribute("LOG");
return ;
}
else{
hres.sendRedirect(errors);
}
}
在JSP页面中 <%session.setAttribute("LOG","true"); %>
这样写 效果也是可以的 但是不知道写好不好 这样的话 那是不是重用性就差了