This file is copied from the struts2 reference. I personally think this image is very helpful for understanding struts2, so I put it on my blog.
In the divisor, an initial request goes to the servlet container (such as jetty or resin) which is passed through a standard filter chain. The chain has des the (optional)ActioncontextcleanupFilter, which is useful when integrating technologies such as sitemesh plugin. Next, the requiredFilterdispatcherIs called, which in turn consults theactionmapper to determine if the request shocould invoke an action.
If the actionmapper determines that an action shoshould be invoked, the filterdispatcher delegates control toActionproxy. The actionproxy consults the frameworkconfiguration files Manager (initialized from the Struts. xml file). Next, the actionproxy createsActioninvocation, Which is responsible for the command pattern implementation. This includes des invoking anyInterceptors(BeforeClause) in advance of invokingActionItself.
Once the action returns, the actioninvocation is responsible for looking up the properResultAssociated withAction result codeMapped inStruts. xml. The result is then executed, which often (but not always, as is the case for action chaining) involves a template written in JSP or freemarker to be rendered. while rendering, the templates can use the struts tags provided by the framework. some of those components will work with the actionmapper to render proper URLs for additional requests.
|
All objects in this architecture (actions, results, interceptors, and so forth) are created by an objectfactory. this objectfactory is pluggable. we can provide our own objectfactory for any reason that requires knowing when objects in the framework are created. A popular objectfactory implementation uses spring as provided by the spring plugin. |
Interceptors are executed again (in reverse order, callingAfterClause). Finally, the response returns through the filters configured inWeb. xml. If the actioncontextcleanup filter is present, the filterdispatcher willNotClean up the threadlocalActioncontext. If the actioncontextcleanup filter is not present, the filterdispatcher will cleanup all threadlocals.
Note: Unlike struts1, struts2 creates an action for each user request, so struts2 action is thread-safe.
The action in struts1 is Singleton (Singleton), and the action in struts2 is prototype (prototype.