上面是我写的放行方法,不登陆账号,可以查看列表、登录账号,想修改、删除等操作页面,回跳转到登录界面。我想问下有没有其它的好方法来写放行呢?
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request2 = (HttpServletRequest)request ;
HttpServletResponse response2 = (HttpServletResponse)response;
HttpSession session = request2.getSession();
User dl = (User) session.getAttribute("dl");
String url = request2.getRequestURI();
if(dl!=null){
chain.doFilter(request , response);
}else if(url.contains("LoginServlet")){
chain.doFilter(request , response);
}else if(url.contains("SeachLbServlet")){
chain.doFilter(request , response);
}else{
response2.sendRedirect("LoginServlet");
}
}