How SpringMVC works

(1) Initiate a request to the front-end controller (DispatcherServlet);
(2). The front-end controller requests HandlerMapping to find a Handler, which can be searched according to xml configuration and annotations;
(3). The processor mapper HandlerMapping returns a Handler to the front-end controller ;
(4). The front controller calls the processor adapter to execute the Handler;
(5). The processor adapter executes the Handler;
(6). The Handler execution completes and returns the ModelAndView to the adapter;
(7). The processor adapter sends the front controller to the Return ModelAndView (which is an underlying object of the springmvc framework, including Model and View);
(8). The front controller requests the view resolver to perform view resolution, and resolves the real view (jsp...) according to the logical view name;
(9 ) ). The view parser returns View to the front controller;
(10). The front controller performs view rendering, and view rendering is to fill the model data (in the ModelAndView object) into the request field.
(11). The front-end controller responds to the result to the user.
4. Component introduction
1. Front-end controller DispatcherServlet (no need for siege lion development), provided by the framework
  Function: Receive requests, respond to results, equivalent to repeaters, central processing units. With dispatcherServlet reduces the coupling between other components.
       When the user request arrives at the front controller, it is equivalent to c in the mvc mode. The dispatcherServlet is the center of the entire process control. It calls other components to process the user's request. The existence of the dispatcherServlet reduces the coupling between the components.
2. Handler Mapping (no need for siege lion development), provided by the framework
  Function: Find Handler according to the requested url Handler
       Mapping is responsible for finding Handler or handler according to user requests, springmvc provides different mappers to implement different mapping methods , for example: configuration file method, implementation interface method, annotation method, etc.
3. The role of the processor adapter HandlerAdapter
  : according to the specific rules (rules required by the HandlerAdapter), the Handler executes
       the processor through the HandlerAdapter. This is the application of the adapter mode. By extending the adapter, more types of processors can be executed.
4. Handler (need to develop)
  Note: When writing Handler, follow the requirements of HandlerAdapter, so that the adapter can execute Handler correctly.
     Handler is the back-end controller following the DispatcherServlet front-end controller, under the control of DispatcherServlet Handler handles specific user requests.
     Since Handler involves specific user business requests, it is generally necessary to develop Handler according to business requirements.
5. View resolver View resolver (no need for siege lion development), provided by the framework
  Function: perform view resolution, and resolve it into a real view (view) according to the logical view name
  The View Resolver is responsible for generating the View view from the processing result. The View Resolver first resolves the logical view name into the physical view name, that is, the specific page address, then generates the View view object, and finally renders the View to display the processing result to the user through the page. The springmvc framework provides many types of View views, including: jstlView, freemarkerView, pdfView, etc.
  In general, model data needs to be displayed to users through page tags or page template technology, and specific pages need to be developed by Siege Lion according to business needs.
6. View View (need to develop jsp...)
  View is an interface, and the implementation class supports different View types (jsp, freemarker, pdf...)

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325979056&siteId=291194637