标签:
http://struts.apache.org/docs/big-picture.html
1. HttpServletRequest 穿越各个过滤器到达FilterDispatcher(这个已经不再使用,现在使用StrutsPrepareAndExecuteFilter)
2. 执行doFilter方法,如果模式不匹配,则进入下一个过滤链
3. 如果匹配则创建上下文(为每个请求创建实例,线程安全)
4. 根据ActionMapping 判断是否应该调用Action
5. 如果需要调用Action则把控制委派给ActionProxy
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException { HttpServletRequest request = (HttpServletRequest) req; HttpServletResponse response = (HttpServletResponse) res; try { if (excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) { chain.doFilter(request, response); } else { prepare.setEncodingAndLocale(request, response); prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); request = prepare.wrapRequest(request); ActionMapping mapping = prepare.findActionMapping(request, response, true); if (mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if (!handled) { chain.doFilter(request, response); } } else { execute.executeAction(request, response, mapping); } } } finally { prepare.cleanupRequest(request); } }
6. 查询配置文件
7. 创建ActionInvocation ,它与拦截器的关系如下:
/** * Override to handle interception */ public abstract String intercept(ActionInvocation invocation) throws Exception;
8.调用拦截器栈、action类
9. action返回结果,有可能渲染jsp等模板,其中会发起额外的请求
10. 渲染完毕调用拦截器栈
11. HttpServletResponse通过过滤器
12. client得到响应
Apache Struts 2 Documentation Big Picture
标签:
原文地址:http://www.cnblogs.com/zno2/p/4930867.html