Struts2 的工作原理
2024-08-31 11:00:10
Struts2 的工作原理: 1)client向server发出一个http请求。webserver对请求进行解析,假设在StrutsPrepareAndExecuteFilter的请求映射路径(在web.xml中配置)中匹配到了该请求,那么webserver就会把该请求转发给DispatcherServleStrutsPrepareAndExecuteFilter进行处理。
2)StrutsPrepareAndExecuteFilter推断该请求是否是一个Struts2请求。假设该请求是一个struts2请求,则StrutsPrepareAndExecuteFilter把请求交给ActionProxy处理。
3)ActionProxy创建一个ActionInvocation实例并初始化
4)ActionInvocation调用Action。在ActionInvocation调用Action的前后。涉及到拦截器的调用。
5)Action运行完成后,ActionInvocation会依据struts.xml配置文件调用相应方法并依据返回的结果来渲染相应的视图。 具体调用过程:
1,把Action请求发送给 StrutsPrepareAndExecuteFilter
StrutsPrepareAndExecuteFilter.doFilter() --> ExecuteOperations.executeAction() --> Dispatcher.serviceAction() -->
2,StrutsPrepareAndExecuteFilter把请求的处理交给 ActionProxy
ActionProxy.execute() -->
3,ActionProxy 创建一个 ActionInvocation 的实例,并进行初始化。ActionInvocation 实例在调用 Action 的过程前后,涉及到相关拦截器的调用和对Result的调用
ActionInvocation.invoke() --> Interceptor.intercept()、 ActionInvocation.invokeAction()、ActionInvocation.executeResult() -->
4。在 Action 运行完成后(ActionInvocation.invokeAction())。ActionInvocation 依据 struts.xml 中的配置找到相应的返回结果(ActionInvocation.executeResult()),并把结果(jsp页面)发送到client 下图为 struts2 处理请求的具体流程:
最新文章
- 39行代码实现JS HTML模板(轻量+高效+易用)
- css样式自适应,支持数字
- redis2.8--主从机同步流程
- WCF入门(十)---WCF事务
- JS实现rgb与16进制颜色相互转换
- .NET SQL Server连接字符串句法
- 执行SQL查询脚本
- 《DSP using MATLAB》示例Example6.4
- iOS Learning
- iOS最新企业证书的生成
- [array] leetcode - 39. Combination Sum - Medium
- 使用MBROSTool 工具制作本地硬盘多启动盘的方法总结
- 2017-2018-2 20155228 《网络对抗技术》 实验五:MSF基础应用
- 如何限定函数只在本cpp内有效
- selenium自动化测试原理和设计的分享
- Groovy 设计模式 -- 抽象工厂 模式
- atitit 读书与获取知识资料的attilax的总结.docx
- Java新帮派——数组
- Singer 学习四 可视化数据操作工具
- 【mysql】索引优化记录