在STRUTS2前进行处理FILTER处理

在STRUTS2的FILTER之前 比如StrutsPrepareAndExecuteFilter之前放一个FILTER
可以进行reponse.sendRedirect操作
或者request.getRequestDispatcher().forward操作
如果forward以后要继续经过struts2的FILTER 那么STRUTS2的FILTER要这样配置

<filter-mapping>
  <filter-name>StrutsPrepareAndExecuteFilter</filter-name>
  <url-pattern>/*</url-pattern>
  <dispatcher>REQUEST</dispatcher>
  <dispatcher>FORWARD</dispatcher>
 </filter-mapping>


或者你可以把你的FILTER定义在
struts2的prepareFilter和excuteFilter之间

例子
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);// 调用父类的方法
  }
 }
}

你可能感兴趣的:(jsp,fckeditor)