Go deep into struts2 (III)-working mechanism and execution Flowchart

Source: Internet
Author: User

1 Working Principle 1.1 System Architecture

Figure 2.1 architecture of struts2.0

1.2 Working Mechanism

For the architecture diagram of the previous section, the following describes the execution process step by step.

? The client initializes a request pointing to a Servlet container (such as Tomcat;

? This request goes through a series of filters (these filters have an optional Filter called ActionContextCleanUp, which is very helpful for the integration of Struts2 and other frameworks, such as SiteMesh Plugin );

Note: After struts2.1.3, you do not need to configure the ActionContextCleanUp filter. The filter is used to clear the value stack, but struts will leave its own session and Attribute.

? Next, call struts's StrutsPrepareAndExecuteFilter filter. StrutsPrepareAndExecuteFilter asks ActionMapper to determine whether the request needs to call an Action;

Note: struts used the FilterDispatcher filter in the early days. Currently, StrutsPrepareAndExecuteFilter is widely used. For the name, prepare and execute indicate that they are prepared to refer to the filterinit method, that is, the configuration is imported; the latter indicates that the filtering means that the doFilter method, that is, the request is forwarded to the corresponding action for processing.

? If ActionMapper decides to call an Action, StrutsPrepareAndExecuteFilter will hand over the request processing to ActionProxy;

? ActionProxy queries the framework Configuration file through Configuration Manager and finds the Action class to be called;

? ActionProxy creates an ActionInvocation instance.

? The ActionInvocation instance uses the naming mode for calling. Before and after the Action is called, the call of the relevant Interceptor (Intercepter) is involved.

? Once the Action is executed, ActionInvocation is responsible for finding the corresponding return result based on the configuration in struts. xml. The returned result is usually (but not always, or another Action chain) a template of JSP or FreeMarker to be represented. You can use the tag inherited from the Struts2 framework in the Process of representation. ActionMapper is required in this process.

1.3 running sequence diagram

When you sort out this document, you can find a picture on the Internet. Special Loan.


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: info-contact@alibabacloud.com 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.