关于Filter中url-pattern的简单问题
就是简单的判断session值的问题,如果session为空,则跳转到login.do
但是web.xml中应该如何配置?
登录页面的路径和其他页面的路径在同一个路径下面:
http://localhost:8080/project/...
这样似乎不行啊,因为每次跳转到login.do之后,又自动执行了一次filter,这样不断进入死循环了!
有没有办法来改正一下?
doFilter代码如下
String userId = (String)httpServletRequest.getSession().getAttribute("userId"); try{ if(userId != null){ filterChain.doFilter(request, response); } else{ httpServletResponse.sendRedirect("http://localhost:8080/Medinet/login.do"); } } catch(Exception ex) { ex.printStackTrace(); }