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 处理请求的具体流程:

最新文章

  1. 39行代码实现JS HTML模板(轻量+高效+易用)
  2. css样式自适应,支持数字
  3. redis2.8--主从机同步流程
  4. WCF入门(十)---WCF事务
  5. JS实现rgb与16进制颜色相互转换
  6. .NET SQL Server连接字符串句法
  7. 执行SQL查询脚本
  8. 《DSP using MATLAB》示例Example6.4
  9. iOS Learning
  10. iOS最新企业证书的生成
  11. [array] leetcode - 39. Combination Sum - Medium
  12. 使用MBROSTool 工具制作本地硬盘多启动盘的方法总结
  13. 2017-2018-2 20155228 《网络对抗技术》 实验五:MSF基础应用
  14. 如何限定函数只在本cpp内有效
  15. selenium自动化测试原理和设计的分享
  16. Groovy 设计模式 -- 抽象工厂 模式
  17. atitit 读书与获取知识资料的attilax的总结.docx
  18. Java新帮派——数组
  19. Singer 学习四 可视化数据操作工具
  20. 【mysql】索引优化记录

热门文章

  1. python字符串中的单双引
  2. Solr.NET快速入门(三)【高亮显示】
  3. 代理模式(Proxy)C++实现
  4. BluetoothA2dp蓝牙音箱的连接
  5. 【Oracle】恢复丢失的临时表空间文件
  6. UWP Tiles
  7. Linux 中文件名颜色所代表的属性
  8. BZOJ 1123: [POI2008]BLO 求割点_乘法原理_计数
  9. ES2015 模板字符串 ``
  10. centos7部署openvasV9