Home  >  Article  >  Java  >  An article to help you understand the evolution of the MVC application model in JavaWeb

An article to help you understand the evolution of the MVC application model in JavaWeb

无忌哥哥
无忌哥哥Original
2018-07-19 09:39:451847browse

The development process of MVC

MVC design pattern

##MVC pattern (Model-View-Controller) is a A software architecture model that divides the software system into three basic parts: Model, View and Controller.

MVC can facilitate the later maintenance and expansion of the program, and facilitate the reuse of certain parts of the program. And MVC also simplifies the program and makes it more intuitive.

l Controller: Processes requests and is responsible for forwarding requests;

l View: Interface designers design graphical interfaces;

l Model Model: Functions of programming application (implementation of algorithms, etc.), database management;

Note that MVC is not Java Things, almost all software with B/S structure now adopts the MVC design pattern. However, it should be noted that MVC has not been fully implemented in B/S structure software. For example, there will be no event drive in our future B/S software!

JavaWeb and MVC

JavaWeb has experienced three periods: JSP Model1, JSP Model1 second generation, and JSP Model2.

JSP Model1 first generation

JSP Model1 is an early model of JavaWeb. It is suitable for small Web projects and has low development costs! During the first generation of Model1, there were only JSP pages on the server side, and all operations were performed in the JSP pages. Even the API for accessing the database was completed in the JSP pages. In other words, everything is coupled together, which is extremely detrimental to later maintenance and expansion.

JSP Model1 second generation

The second generation of JSP Model1 has been improved and put the business logic content into JavaBean, while JSP The page is responsible for display and request scheduling. Although the second generation is better than the first generation, it still requires JSP to do too much work. In JSP, the view work and the request scheduling (controller) work are coupled together.

JSP Model2

JSP Model2 mode can clearly see the complete structure of MVC.

l JSP: View layer, used to deal with users. Responsible for receiving the used data and displaying the data to the user;

l Servlet: Control layer, responsible for finding the appropriate model object to process the business logic and forwarding it to the appropriate view;

l JavaBean: Model layer, completes specific business work, such as opening, transferring, etc.

JSP Model2 is suitable for multiple people to cooperate in the development of large-scale Web projects. Each person performs his own duties without interfering with each other, which is conducive to the division of labor in development and the reuse of components. However, the development of Web projects has become more difficult, and the technical requirements for developers have also increased.

JavaWeb classic three-tier framework

The three-tier framework we often say was proposed by JavaWeb, which means it is unique to JavaWeb of!

The so-called three layers are the presentation layer (WEB layer), business logic layer (Business Logic), and data access layer (Data Access).

l WEB layer: Contains WEB-related content such as JSP and Servlet;

l Business layer: The business layer does not include JavaWeb API , it only cares about business logic;

l Data layer: encapsulates the details of access to the database;

Note that it cannot be used in the business layer JavaWebAPI appears, such as request, response, etc. In other words, the business layer code is reusable and can even be applied to non-Web environments. Each method in the business layer can be understood as a universal method, such as the transfer business method. The business layer depends on the data layer, and the web layer depends on the business layer!

The above is the detailed content of An article to help you understand the evolution of the MVC application model in JavaWeb. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn