Struts of WebMVC framework and struts of webmvc framework

Source: Internet
Author: User

Struts of WebMVC framework and struts of webmvc framework

In the previous blog, we introduced the main functions implemented by the WebMVC framework. It provides us with basic services, making it simple, flexible, and configurable for MVC-based development. This article mainly introduces the main content of Struts in the WebMVC framework.

 

Development Process

Shows the basic Struts-based development process:





In the web. configure the requests intercepted by the ActionServlet in xml. The ActionServlet provided by Struts acts as the front-end controller and processes the client requests, the main content it handles is the same as the content introduced in the previous blog: In, actionServlet is mainly to read the configuration information in the struts-config.xml to intercept the URL address, convert the form data type, encapsulate the form data, distribute the request to the Action (Business Controller), get the steering information to turn ......

We can see that Struts is mainly used to enhance the C in MVC, so that we do not have to worry too much about the specific logic judgment function.


Main Content

The main functions of Struts are summarized as follows:


The main functional services provided by Struts for developers are listed. The Controller part is the main content and covers the content to be mastered in the Struts-based development process.

Core objects:

ActionServlet and Action have been highlighted before as controllers;

ActionForward encapsulates the redirection information, which is also the object to be returned by the ActionServlet after the Action is executed.

ActionMapping encapsulation information, in fact, for the configuration in the struts-config.xml, provides runtime support for the first few objects, that is to say, when the service starts, the configuration information has been encapsulated into ActionMapping, when the program is running, it mainly obtains the relevant configuration from it and then executes the operation.

In addition to the above core objects, the ActionForm object is also a major feature of Struts. It mainly encapsulates the data submitted by the form. After the ActionServlet receives the browser request, the registered type converter is called to convert the form data in the request and encapsulate the data in a specific ActionForm. This solves the tedious problem of manual conversion of form data.

 

It must be mentioned that, in order to reduce the configuration volume, code volume, and meet the requirements of flexible processing, Struts provides a dynamic creation mechanism for ActionForm and ActionForward. ActionForm is not mandatory, if necessary, you can use the configuration method for dynamic creation. ActionForward can also be dynamically created within the program to flexibly respond to different requirements for page redirection.

In addition, in terms of configuration reduction and code reduction, Struts is superior to the configuration in terms of conventions. It also provides the function of pattern matching and DispathAction to reduce the number of actions.

In terms of internationalization, Struts further encapsulates java-based internationalization (Locale, ResourceBundle, etc. First, the international resource file is stored by the name of BaseName + Locale. property, and the ActionMessage is stored and transmitted. On the JSP page, labels provided by Struts are used for easy reading. Other Struts exception handling methods are closely integrated.

 

Summary

Through Struts learning and practice, I have mastered the MVC-based development process and understood the functions provided by a WebMVC framework, this also provides a general direction for other similar frameworks.



Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.

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.