Struts2-Architecture Analysis

Source: Internet
Author: User

Struts2-Architecture Analysis

I. xwork2 --- basics of struts2

The struts2 framework consists of xwork and struts2. Xwork is a command mode framework, which is the basis of struts2. Xwork provides many core functions: IOC (control reversal) Containers, powerful expression language, data type conversion, validation, and pluggable configuration. The core of the xwork framework is action, interceptor, and result. Struts2 extends the basic implementation of these concepts to Support web application development.

In struts2, interceptor is an important concept. The interceptor can execute code before and after the action is called. Most of the core functions of the struts2 framework are implemented as interceptors. Such as type conversion, object assembly, verification, avoiding repeated form submission, and file upload, are all implemented with the help of the interceptor. Collaboration between struts2 interceptor and xwork interceptor.

How struts2 interceptor works

Interaction between struts2 and xwork

Architecture of struts2

 

The process of a request in the Struts2 framework is roughly divided into the following steps:

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

2. 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 );

3. FilterDispatcher is called. FilterDispatcher asks ActionMapper to determine whether the request needs to call an Action;

4. If ActionMapper decides to call an Action, FilterDispatcher submits the request processing to ActionProxy;

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

6. ActionProxy creates an ActionInvocation instance.

7. 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.

8. 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.

 


 

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.