日期:2014-05-18 浏览次数:20715 次
public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { HttpServletRequest httpRequest = (HttpServletRequest)request; HttpServletResponse httpResponse = (HttpServletResponse) response; HttpSession session = httpRequest.getSession(); if(session.getAttribute(ApplicationSource.USER) == null && !httpRequest.getRequestURI().endsWith("/login.jsp") // 这些都是一些需要排除的页面 && !httpRequest.getRequestURI().endsWith("/calendar/") && (httpRequest.getRequestURI().indexOf("/calendar/img") < 0) && (httpRequest.getRequestURI().indexOf("/calendar/resources") < 0) && (httpRequest.getRequestURI().indexOf("/calendar/servlet") < 0) && !httpRequest.getRequestURI().endsWith("/login.do")){ httpResponse.sendRedirect(httpRequest.getContextPath() + "/login.jsp"); } chain.doFilter(request, response); }