过滤器Filter IllegalStateException 重定向问题
public void doFilter(ServletRequest req, ServletResponse res,FilterChain arg2) throws IOException, ServletException {HttpServletRequest request = (HttpServletRequest) req;HttpServletResponse response = (HttpServletResponse) res;String path = request.getServletPath();HttpSession session=request.getSession();System.out.println(path);Object obj=session.getAttribute("LoginColleges");if (!"/index.jsp".equals(path)) {if (obj == null) {response.sendRedirect("/hveda/index.jsp");[color=red]return;[/color]}}if (path.contains("ByAdmin")) {if (!(obj instanceof Colleges)) {response.sendRedirect("/hveda/index.jsp");[color=red]return;[/color]}arg2.doFilter(req, res);}1 楼 lizhen1643 2011-06-01 为什么要用重定向? 我看你的URL并没有跨域啊。怎么不用请求转发? 2 楼 lrysir 2011-06-01 这个使用重定向是个人习惯.... 感谢你的提醒! 我会注意的 3 楼 raypominfo 2011-06-02 为啥要用转发呢?