Why do I need MVC?
Earliest Javaweb development: servlet==java+ "HTML", Problem: stitching strings in servlets too cumbersome
Later appeared jsp:==html+java nested Java code in Html, problem: page and logic too mixed
resulting in: The Birth of MVC!
MVC is an architectural pattern that does not introduce new functions in itself, which is to guide us to make the Web application structure well
Features: independent of function
Goal: Separating logic from the page
MVC pattern: Model, view, control: Models, views, controllers
1: Model: Contains business logic and business data for an application
2: View: Contains the output form of the application, namely: page or interface
3: Controller: Responsible for coordinating the model and view;
Select which model to invoke to handle the business based on user requests
and finally which view to answer for the user!
Models and views in MVC are decoupled and decoupled, and the same model can correspond to many different views
Specific features:
Model:
Package Application Status---------> Data encapsulation
Response status Query----------> Get Data
Exposing the functionality of your app-----------> logic Layer API
View:
Provides HTML form for user request-------> man-Machine interaction
Request update-------> Trigger events for a model
Generating HTML responses-------> Presentation Data
Controller:
Receive and validate data from HTTP requests--------> Collect data and encapsulate data
Map user data to updates to the model--------> invoke the Logical Layer API
Select the view to use for the response---------> select the next page based on the return value
Pure JSP applications
Without MVC, the system structure diagram is as follows:
This structure is not very good, in the JSP page write too much code, especially control code, business and logic
is too mixed, so you need to introduce a middle-tier----controller that specifically handles the control code
The standard MVC build diagram is as follows:
What is MVC and what