Struts2运行流程分析
2015-12-08 22:39
423 查看
一.Struts2运行流程图:
二.运行流程分析:
1. 请求发送给StrutsPrepareAndExecuteFilter
2.StrutsPrepareAndExecuteFilter询问ActionMapper:该请求是否是一个Struts2请求(即是否返回一个非空的ActionMapping对象)
3. 若ActionMapper认为该请求是一个Struts2请求,则StrutsPrepareAndExecuteFilter把请求的处理交给ActionProxy
4. ActionProxy通过ConfigurationManager 读取框架的配置文件,确定需要调用的Action类及Action方法
5. ActionProxy创建一个ActionInvocation的实例,并进行初始化
6. ActionInvocation实例在调用Action的过程前后,涉及到相关拦截器(Intercepter)的调用。
7.Action执行完毕,ActionInvocation负责根据struts.xml中的配置找到对应的返回结果。调用Result的execute方法,渲染结果。在渲染的过程中可以使用Struts2框架中的标签。
8. 执行各个拦截器invocation.invoke()之后的代码
9. 把结果发送到客户端
三、相关API
•ActionMapping:Simpleclass that holds the action mapping information used to invoke a Struts action.The name and namespace arerequired
•ActionMapper:Whengiven anHttpServletRequest, theActionMapper
mayreturn null if no action invocation request matches, or it may return anActionMapping thatdescribes an action invocation for the framework totry
•ActionProxy:ActionProxy isan extra layer betweenXWork andthe
action so that different proxies are possible.
•ActionInvocation:AnActionInvocation represents the execution state of an Action. It holds the
Interceptors and the Action instance. By repeated re-entrant execution of the invoke() method,initially by theActionProxy,then by the Interceptors, the Interceptors are all executed, and then
the Action and the Result.
二.运行流程分析:
1. 请求发送给StrutsPrepareAndExecuteFilter
2.StrutsPrepareAndExecuteFilter询问ActionMapper:该请求是否是一个Struts2请求(即是否返回一个非空的ActionMapping对象)
3. 若ActionMapper认为该请求是一个Struts2请求,则StrutsPrepareAndExecuteFilter把请求的处理交给ActionProxy
4. ActionProxy通过ConfigurationManager 读取框架的配置文件,确定需要调用的Action类及Action方法
5. ActionProxy创建一个ActionInvocation的实例,并进行初始化
6. ActionInvocation实例在调用Action的过程前后,涉及到相关拦截器(Intercepter)的调用。
7.Action执行完毕,ActionInvocation负责根据struts.xml中的配置找到对应的返回结果。调用Result的execute方法,渲染结果。在渲染的过程中可以使用Struts2框架中的标签。
8. 执行各个拦截器invocation.invoke()之后的代码
9. 把结果发送到客户端
三、相关API
•ActionMapping:Simpleclass that holds the action mapping information used to invoke a Struts action.The name and namespace arerequired
•ActionMapper:Whengiven anHttpServletRequest, theActionMapper
mayreturn null if no action invocation request matches, or it may return anActionMapping thatdescribes an action invocation for the framework totry
•ActionProxy:ActionProxy isan extra layer betweenXWork andthe
action so that different proxies are possible.
•ActionInvocation:AnActionInvocation represents the execution state of an Action. It holds the
Interceptors and the Action instance. By repeated re-entrant execution of the invoke() method,initially by theActionProxy,then by the Interceptors, the Interceptors are all executed, and then
the Action and the Result.
相关文章推荐
- Struts2运行流程分析
- Eclipse常用快捷键
- 【Java编程】使用增强for循环和迭代器遍历Map集合
- JAVA学习笔记之运算符
- maven创建多bundle的springMVC框架模块简单概述(补充中)
- day_35Java多线程4
- struts2中"input"表示什么含义?
- 在eclipse中将android项目生成apk并且给apk签名
- Java实现几种常见排序方法
- 在eclipse中怎样给项目添加关联项目
- 单元测试(SpringMVC)
- Java enum的用法详解
- 关于SpringMVC(2)
- eclipse设置关联文件打开方式
- LensKit<开源推荐系统框架Java>学习笔记
- elasticsearch2.0学习之路(二)java api
- eclipse使用fatjar打包成exe
- Java——集合<>
- spring生命周期
- Struts2中的OGNL详解