UnFindBugs
UnFindBugs
2017-09-27 12:44

filter过滤器进入死循环怎么解决?

  • filter

代码如下:
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
HttpServletRequest req=(HttpServletRequest)request;
HttpServletResponse res=(HttpServletResponse)response;
Object user =req.getSession().getAttribute("userName");
System.out.println("过滤中");
String urlString = req.getRequestURI();
if(urlString.endsWith("login.jsp")||urlString.endsWith("LoginFilter")){
chain.doFilter(request,response);
return;
}

else if(user==null){
res.sendRedirect("../jsp/login/login.jsp");
}else{
chain.doFilter(request, response);
}
}
配置如下:

LoginFilter
com.gpeight.hotel.filter.LoginFilter


LoginFilter
/*

  • 点赞
  • 回答
  • 收藏
  • 复制链接分享

1条回答

为你推荐