在STRUTS2前进行处理FILTER处理
在STRUTS2的FILTER之前 比如StrutsPrepareAndExecuteFilter之前放一个FILTER
可以进行reponse.sendRedirect操作
或者request.getRequestDispatcher().forward操作
如果forward以后要继续经过struts2的FILTER 那么STRUTS2的FILTER要这样配置
public class SwpFilter extends StrutsPrepareAndExecuteFilter { public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse reponse = (HttpServletResponse) res; //在这里进行URLREWRITE的操作 if (request.getRequestURI().equals("/aa")) { request.getRequestDispatcher("swp/getResource?type=page&id=609&edit=true").forward(req, res); return; } if (request.getServletPath().startsWith("/fckeditor")) { super.doFilter(req, res, chain); } else if (request.getServletPath().equals("/manager/")) { reponse.sendRedirect(request.getRequestURI() + "manager.jsp"); } else if (request.getServletPath().equals("/login")) { reponse.sendRedirect("manager/login.jsp"); } else if (request.getServletPath().equals("/login/")) { reponse.sendRedirect("../manager/login.jsp"); } else { super.doFilter(req, res, chain);// 调用父类的方法 } }}