Struts2学习总结(一):Struts2结构体系

来源:互联网 发布:做淘宝网店 编辑:程序博客网 时间:2024/06/03 22:07

 Struts2是基于WebWork技术开发的全新框架,结构体系图如下:



一个请求在Struts2框架中的处理流程大概分为以下几个步骤:

1. 请求发送给 StrutsPrepareAndExecuteFilter
2. StrutsPrepareAndExecuteFilter 询问 ActionMapper(Action映射器-包含了name and namespace ): 该请求是否是一个 Struts2 请求(即是返回一个非空的 ActionMapping 对象)
3. 若 ActionMapper 认为该请求是一个 Struts2 请求,则 StrutsPrepareAndExecuteFilter 把请求的处理交给 ActionProxy(Action代理,是Xwork和Action的中间层)
4. ActionProxy 通过 Configuration Manager (配置管理器)询问框架的配置文件,确定需要调用的 Action 类及 Action 方法
5. ActionProxy 创建一个 ActionInvocation ( ActionInvocation就是Action的调用者。ActionInvocation在Action的执行过程中,负责Interceptor、Action和Result等一系列元素的调度。)的实例,并进行初始化
6. ActionInvocation 实例在调用Action的过程前后,涉及到相关拦截器(Intercepter)的调用。
7. Action 执行完毕,ActionInvocation 负责根据 struts.xml 中的配置找到对应的返回结果。调用结果的 execute 方法,渲染结果。在渲染的过程中可以使用Struts2 框架中的标签。
8. 执行各个拦截器 invocation.invoke() 之后的代码
9. 把结果发送到客户端


原创粉丝点击