Struts 2 introduces and runs a simple Struts 2 program

Source: Internet
Author: User

A brief introduction of MVC

To sum up, the advantages of MVC are mainly as follows:

1 multiple views can correspond to a model. According to MVC design pattern, a model corresponding to multiple views, can reduce code duplication and code maintenance, once the model changes, it is easy to maintain

2 The data returned by the model is separated from the display logic. Model data can be applied to any display technology, such as using JSP pages, velocity templates, or directly producing Excel documents

3 application is divided into three layers, reducing the coupling between the layers, providing the scalability of the application

4 The concept of the control layer is also very effective, because it combines different models and different views to complete different requests. Therefore, the control layer can be said to contain the concept of user request permission

5 MVC is more in line with the spirit of software engineering management. Different layers, each layer of components have the same characteristics, is conducive to the adoption of engineering and tooling to generate management program code

The concept of MVC is also nonsense to this, the key is the implementation of each module is what the technology respectively.

Ii. introduction of Struts2

STRUTS2 is an MVC framework compatible with STRUTS1 and webwork.

STRUTS2 's simple processing process is as follows:

1) Browser Send request

2 The Center processor finds the corresponding action class for the processing request according to the Struts.xml file

3 WebWork's interceptor chain automatically applies common functions to requests, such as: WorkFlow, validation and other functions

4 If the method parameter is configured in the Struts.xml file, then the methods in the action class corresponding to the way parameter are invoked, otherwise the generic Execute method is invoked to handle the user request

5 respond to the browser the result returned by the corresponding method in the Action class

Three, Struts2 and Struts1 contrast

................................

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.