Ssh-Struts (1)-Basic Principles

Source: Internet
Author: User
IntroductionThe Struts framework is an implementation of MVC. It combines JSP, Servlet, JavaBean, taglib, and other technologies. It provides good support for MVC layers, just like the building framework built by real estate agents before building a house. As long as the project is introduced, you already have a basic prototype.
OK. I don't think this is a good starting point to understand the technical knowledge at the conceptual level. The best way to learn this kind of knowledge is to start. Therefore, we do not seek accurate conceptual definitions, but recognize them in terms of use.
Looking back at MVC as an implementation of MVC, we should first briefly review the content of MVC before learning. The MVC Architecture Model divides an application's access, processing, and output processes into the model layer, view layer, and control layer. The relationships and functions of each layer in MVC mode are shown in figure (Note: The picture is from page 443 of "conquer JSP enterprise website development ):

Everything about MVC is in this forum. Here is a question: the relationship between MVC and layer-3. I have heard a lot of discussions about these two models. The conclusion is basically that they do not matter. I personally think this is to optimize the program structure from two different perspectives. MVC is divided from the processing process perspective: Display, control, and processing; the three layers are from the functional perspective: Display, logical processing, data access. These two modes do not conflict! Their relationship is such a relationship. It cannot be simply said that there is or there is no relationship, it is a bit too rough.

Model1 model1 is also a type of MVC, which is implemented through JSP + JavaBean. The JSP page can easily write the code of JavaBean involving the business logic. It can also be used in combination with HTML for display and controlled by JavaScript. In other words, JSP plays multiple roles in the application: It is responsible for communicating with the client, processing requests, and processing replies. This structure is simple and convenient, allowing you to quickly complete application development. At the same time, this structure also makes it difficult to allocate and maintain the development. It is a model1 structure (Note: Source: struts practical development guide for Java Web application development based on MVC + myeclipse 3)

Model2 introduces Servlet as a controller to improve the problem caused by too many complaints on JSP pages in the model. At the same time, it does not write Java code in JSP to directly access the database. In this way, each part of the program has a single responsibility, that is, the JSP page is only responsible for display, servlet is responsible for circulation. In this way, it is relatively easy to maintain, and the division of labor during development can also be determined. The disadvantage of doing so is that the processing process becomes complicated. The work that can be done by a JSP can only be completed in multiple steps. The structure of model2, for example, (note: The image source is the same as the previous one, 5 pages ):

Struts mode1 and model2 are concepts, while sturts is implementation. Struts is an implementation of MVC. To be precise, it should be the implementation of model2. Let's look at the figure directly:
Struts implements all parts of model2, but the most important part is the page flow. That is, the part of the actionservlet + struts-config.xml in the figure, the path of the page flow is very clear, and the flexibility is also very good.
Summary: This blog is a step-by-step understanding of the concept of MVC to the implementation of struts architecture, so that you can know the concept of MVC corresponding to each part of struts and the role in the application. The detailed struts components will be introduced in subsequent blogs. That's it!

Ssh-Struts (1)-Basic Principles

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.