"DIY Series" hands-on implementation Struts2 Framework (i) Principle analysis

Source: Internet
Author: User
Tags xml parser

I. Struts concept

STRUTS2 is an architecture that embodies the idea of separation of concerns.

Struts2 Encapsulates all the details that need to be handled in our web development into interceptors (interceptor), each of which is responsible for its own independent functions.

Example: Parameter blocker (params), token blocker (interceptor-stack)

We can also specify our own interceptors to extend the functionality of the STRUTS2 (custom interceptors)


two. features of Struts2 1. Separation/decoupling of focus points

The patchwork of change points is encapsulated in different parts of the software system.

One part of the system has changed, without affecting the other parts

Even if you need to change, you can clearly identify which parts need to be changed.

If you need to expand the architecture, minimize the impact, and the already working part of the US will continue to work.

2.mvc

Struts2 also embodies the design idea of MVC.

Controller C (strutsprepareandexecutefilter) is the STRUTS2 core class we declared in Web. xml

Model M (Action)

View V (JSP)

three. Struts2 processfigures indicate the flow of the request

When a user makes a request

1: First through the STRUTS2 framework of the core controller (Strutprepareandexecutefiler)

2: The core controller finds Actionmapper in turn to determine whether the call to this request invokes action. If Actionmapper decides to invoke action, the core controller delegates the requested processor control to Actionproxy

3:actionproxy A new configuration file (Struts.xml) for the struts framework through Configuration Manager, the action class to invoke

4: then Actionproxy creates an actioninvocation instance that is responsible for the implementation of the command pattern, including any interceptor that activates the action.

5: After the action execution completes, the Actioninvocation instance is responsible for finding the desired result in the Struts.xml configuration file based on the return result code of the action. The result is usually a JSP or Freemarker template. It may also be action.

6:action configured interceptors will be executed again (reverse execution order and call)

7: The server response will be returned through the STRUTS2 Framework core controller configured in the Web. xml file.


(The next article will tell you: manually implement the STRUTS2 framework)

The reader is required to understand the following knowledge points:

1.xml Parser, XPath expression ( dom4j)

2.Servlet Technology

3.java Introspection ( beanutils)

4.ThreadLocal thread Localization class

5. Recursive invocation

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

"DIY Series" hands-on implementation Struts2 Framework (i) Principle analysis

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.