1. Introduction to the MVC pattern
M-model model
The role of model is to be responsible for business logic. Consists of two tiers: business data and business processing logic. For example, entity class, DAO, service all belong to model layer.
V-view View
The view's responsibility is to display the interface and user interaction (mobile user information). A component that belongs to a view is a JSP that does not contain business logic and control logic
C-controller Controller
A controller is a bridge between the model layer m and the view layer V for controlling processes such as:
A single controller Actionservlet in a servlet project.
2. What is Spring Web MVC
Spring Web MVC is a very important functional module of the spring Framework. The MVC structure is implemented to facilitate the simple and rapid development of the MVC structure of the Web program. The API provided by Spring Web MVC encapsulates the functionality of web development and simplifies the web process.
3. Core components of Spring WEB MVC
Spring WEB MVC provides the main implementation components related to M, V, and C, as follows:
Dispatcherservlet (Controller, request entry)
Handlermapping (Controller, request dispatch)
Controller (Director, request processing process)
Modelandview (model, encapsulating Business processing results and views)
Viewresolver (view, view display processor)
4. Spring Web MVC Processing flow
The browser sends a request to spring and requests it to the front-end controller Dispatcherservlet processing
The controller uses handlermapping to find the appropriate controller component to process the request
The Execute Controller component contract method processes the request, and the contract method invokes the model component to complete the business processing. The contract method can return a Modelandview object that encapsulates the processing result data and the view name information
After the controller accepts Modelandview, it calls the Viewresoler component, locates the view (JSP) and passes the data information to generate the response interface result
5.
Spring Web MVC Basics