Struts 2 architecture diagram and description

Source: Internet
Author: User

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.