Article 4: Design mode and struts introduction articles
Serious warning: People only care about the program, please skip
Prior statement: This article is all introduced, and there is no programming at all. All of this article is not your own work. There is no way to modify, just deleting some content. Why add this content? I can understand what? Waiting for the problem, I don't know, but I have to declare that I don't feel nonsense.
Design mode (Design Patten)
Simply put, Design Patten is a commonly used solution. During our development, you will often encounter some of the same or similar problems. Every time we will find a new solution, in order to save time improvement, we provide some to solve these common problems, proven to be feasible. The solution constitutes a unified repository.
A Design Patten describes a proven program. These programs are very common, and it is the most commonly defined pattern with a complete definition. These modes can be reused, and there is good scalability.
MVC design mode
Code separation, display and logical decoupling
Verification process
Process control
Update the status of the application
The MVC helps solve certain problems encountered by the single module method by dividing the problem into three categories.
Model, View, Controller (Controller)
MODEL (model)
The model contains the core of the application, which encapsulates the application's data structure and transaction logic, which reflects the status of the application. Sometimes it only contains status information because it does not understand the information of the window or controller (it does not know anything at any time).
JavaBean and EJB are ideal for this role because it can handle most of the transaction logic and data structures. It can interact with databases or file systems, and bear responsibility for maintaining application data.
View (view)
The view implements the appearance of the module, which is an external manifestation of the application. It can access the model of the model, but does not understand the model, and it does not understand the situation of the controller. When the model changes, the view will be notified, it can access the data of the model, but these data cannot be changed.
Controller
The controller reacts to the user's input and links the model and view. The servlet can accept the client's HTTP request and create the required JavaBean or EJB as needed, and then notify the window to the window.
MVC Model 2 mode for web applications
Features of the web application:
Customized connection of clients and servers
Since the HTTP itself lacks state information, the client must retrore the server to find changes caused by the input, in which case the controller does not notify the application.
Implementing the techniques used in views and implementation of models or controllers.
You can also use Java code to generate all HTMLs, but this will produce more questions.
For web applications, you need to modify the standard MVC form. The figure below shows the MVC web rewrite version, typically also known as MVC Model 2 or MVC 2.