Home  >  Article  >  Java  >  Spring+SpringMVC+MyBatis in-depth learning and construction-SpringMVC architecture

Spring+SpringMVC+MyBatis in-depth learning and construction-SpringMVC architecture

巴扎黑
巴扎黑Original
2017-06-26 09:54:331632browse

Please indicate the source for reprinting:

As mentioned earlier: Spring+SpringMVC+MyBatis in-depth learning and construction (10)-MyBatis reverse engineering

1. What SpringMVC

Spring web mvc and Struts2 both belong to the presentation layer framework, which is a module of the Spring framework. SpringMVC and Spring do not need to be integrated through an intermediate integration layer.

SpringMVC is a web framework based on mvc.

2. Application of mvc in b/s system

(1) The user initiates a request request to the control Controller

The control receives the data requested by the user and delegates it to the model for processing.

(2) The controller processes data through the model (Model) and obtains the processing results

Model usually refers to business logic

(3) The model processing results are returned to the controller

(4) The controller displays the model data in the view

The model in the web cannot display the data directly on the view, it needs to be completed through the controller. If the model is in a C/S application, the data can be displayed in the view.

(5) The controller responds with the view response to the user

Display the data or processing results required by the user through the view.

3.SpringMVC framework

3.1 Architecture process

(1) The user sends a request to the front-end controller (DispatcherServlet)

(2) DispatcherServlet receives the request and calls the HandlerMapping processor mapper

(3) The processor mapper finds the specific processor (Handler, which can be searched based on xml configuration and annotations) according to the request url. The generated processor object and the processor interceptor (generated if any) are returned to the DispatcherServlet.

(4) DispatcherServlet calls the processor through the HandlerAdapter processor adapter

(5) Execution processor (Controller, also called back-end controller)

(6) Controller After execution, return ModelAndView

(7) HandlerAdapter returns Controller execution result ModelAndView to DispatcherServlet

(8) DispatcherServlet passes ModelAndView to ViewResolver view resolver

(9) ViewResolver returns the specific View after parsing

(10) DispatcherServlet renders the View (that is, fills the model data into the view)

(11) DispatcherServlet responds to the user

3.2 Components Description

(1) Front-end controller DispatcherServlet (no programmer development required)

Function: Receive requests and response results, equivalent to a forwarder and central processing unit.

With DispatcherServlet, the coupling between other components can be reduced.

(2) Processor mapper HandlerMapping (no programmer development required)

Function: Find Handler according to the requested url

(3) Processor adapter HandlerAdapter

Function: Execute Handler according to specific rules (rules required by HandlerAdapter)

(4) Processor Handler (requires programmer development)

Note: When writing Handler, follow the instructions of HandlerAdapter It is required to do it, and pay attention to the adapter to correctly execute the Handler.

(5) View resolver Viewresolver (does not require programmer development)

Function: who performs the analysis and resolves it into a real view (View) based on the logical view name

(6) View (requires programmers to develop jsp)

View is an interface, and the implementation class supports different View types (jsp, freemarker, pdf....)

The above is the detailed content of Spring+SpringMVC+MyBatis in-depth learning and construction-SpringMVC architecture. 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