[Struts2] workflow and struts2 Workflow

Source: Internet
Author: User
Tags html form

[Struts2] workflow and struts2 Workflow

Forward two articles

 

The process of a request in the Struts2 framework is divided into the following steps: 1. the client sends a request to the servlet container (tomcat); 2. this request will pass through several filters in the figure and finally reach the FilterDispatcher filter. 3. The filter FilterDispatcher is the heart of the struts2 framework. when processing user requests, it and the request work together to access the underlying framework structure of struts2. When a web container is started, the struts2 framework automatically loads parameters in the configuration file and converts them to corresponding classes.
For example, ConfigurationManager, ActionMapper, and ObjectFactory. ConfigurationManager contains some basic information about the configuration file, and ActionMapper contains the configuration information of the action. All objects (actions, Results, Interceptors, etc.) in the request process are created through ObjectFactory.
The filter queries the ActionMapper class to find the Action to be used in the request.
4. If the Action to be called is found, the filter will send the request processing to ActionProxy. ActionProxy is the proxy object of Action. ActionProxy queries the framework configuration file through ConfigurationManager and finds the Action class to be called.
5. ActionProxy creates an ActionInvocation instance. Under the ActionProxy layer, ActionInvocation indicates the execution status of the Action, or the execution steps of the Action it controls. It holds Action instances and all interceptors.
6. The ActionInvocation instance is called in the naming mode. 1. During ActionInvocation initialization, all the interceptors related to the Action are loaded according to the configuration. 2. Execute Interceptor when calling Action implementation through ActionInvocation. invoke method.
Before and after the Action is called, the call of the relevant Interceptor (intercepetor) is involved. 7. 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.

 

Workflow: the process of a request in the Struts2 framework is roughly divided into the following steps: 1. the client sends a request;
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 to call an Action.
4. If ActionMapper decides to call an Action, FilterDispatcher submits the request processing to ActionProxy.
5. ActionProxy asks 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 a JSP or FreeMarker template to be represented (but not always, or another Action chain.

You can use the tag inherited from the Struts2 framework in the Process of representation. In this process, all the objects (actions, Results, Interceptors, etc.) involved in ActionMapper in the above process are created through ObjectFactory.
Struts2's goal is simple-making Web development easier. To achieve this goal, Struts2 provides many new features, such as smart default settings, annotation usage, and application of the "Convention over configuration" principle, all of this greatly reduces the XML configuration.

Actions in Struts2 are all POJO, which enhances the testability of actions and reduces the coupling degree within the framework, the input items in the HTML form are converted into appropriate types for action.

Developers can also pre-process and post-process requests through the Interceptor (which can be customized or the interceptor provided by Struts2). As a result, the process of requests becomes more modular, this further reduces coupling.

Modularization is a general topic-the framework can be expanded through plug-in mechanism; developers can replace the key classes of the framework with custom implementations, to obtain functions not provided by the framework itself;

You can use tags to render multiple themes (including custom themes). After an Action is executed, there are multiple types of results-including rendering JSP pages, Velocity, and Freemarker templates, but not limited to these.

 

 

Original address http://www.cnblogs.com/wangjianbg/p/3555570.html

Http://www.cnblogs.com/bjameng/archive/2011/11/15/2250441.html

 

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.