zoukankan      html  css  js  c++  java
  • Struts2 的工作原理

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


  • 相关阅读:
    log4j.appender.stdout.layout.ConversionPattern
    log4j:WARN No appenders could be found for logger
    Eclipse中TODO的分类,以及自动去除
    Java泛型类型擦除导致的类型转换问题
    Java中泛型数组的使用
    Java泛型中的通配符的使用
    Java泛型类定义,与泛型方法的定义使用
    Java泛型的类型擦除
    jQuery查询性能考虑
    jQuery判断checkbox是否选中
  • 原文地址:https://www.cnblogs.com/jzssuanfa/p/7105268.html
Copyright © 2011-2022 走看看