Struts2 最新版本流程浅析

<!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter" /> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0" /> <v:f eqn="sum @0 1 0" /> <v:f eqn="sum 0 0 @1" /> <v:f eqn="prod @2 1 2" /> <v:f eqn="prod @3 21600 pixelWidth" /> <v:f eqn="prod @3 21600 pixelHeight" /> <v:f eqn="sum @0 0 1" /> <v:f eqn="prod @6 1 2" /> <v:f eqn="prod @7 21600 pixelWidth" /> <v:f eqn="sum @8 21600 0" /> <v:f eqn="prod @7 21600 pixelHeight" /> <v:f eqn="sum @10 21600 0" /> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" /> <o:lock v:ext="edit" aspectratio="t" /> </v:shapetype><v:shape id="图片_x0020_1" o:spid="_x0000_i1025" type="#_x0000_t75" style='width:263.25pt;height:311.25pt;visibility:visible'> <v:imagedata src="file:///C:\DOCUME~1\ADMINI~1\LOCALS~1\Temp\msohtmlclip1\01\clip_image001.png" o:title="" /> </v:shape><![endif]--><!--[if !vml]--><!--[endif]--><!--EndFragment--> :shapet�xi=�� �� 75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <!--[endif]----><!--[if !vml]--><!--[endif]-->

图片看不到   请到我相册查看

 

1  例如  http://localhost:8080/erp/main.action

HttpServletRequest请求来到        web.xml 配置的一系列过滤器各显其能!

他们有ActionContextCleanUp  SiteMesh等等过滤器 但最后的拦截器永远是

StrutsPrepareAndExcuteFilter

2  StrutsPrepareAndExcuteFilter 询问ActionMapper是否需要调用某个Action来处理这个request,ActionMapper同意了,决定需要调用某个Action,然后StrutsPrepareAndExcuteFilter把请求的处理交给ActionProxy

3  Configuration Manager struts.xml进行解析,把结果传递给ActionProxyActionProxy 找到需要调用的Action.

 <package name="main" namespace="/" extends="struts-default">

     <action name="main" class="mainAction" method="main">

          <result>/WEB-INF/jsp/main.jsp</result>

     </action>

 </package>

mainAction 被发现了!

4 ActionProxy创建一个ActionInvocation的实例,同时ActionInvocation通过代理模式调用Action.但在调用之前ActionInvocation会根据配置加载Action相关的所有的Interceptor.

5Action执行完毕,ActionInvocation负责根据struts.xml中的配置找到对应的返回结果。但大部分时候都是返回另外一个action,那么继续执行类似这样的流程

 

 


 

猜你喜欢

转载自332575101.iteye.com/blog/1709919