SpringMVC brief introduction and implementation

Introduction SpringMVC

Spring is Spring MVC provides a powerful and flexible web framework. By means of annotations, Spring MVC provides almost POJO development model, making the development and testing of the controller easier. These controllers generally do not directly process the request, but it will be delegated to other bean Spring context, using the Spring dependency injection, the bean is injected into the controller.

SpringMVC core components

  • DispatcherServlet: role: receiving a request, a response result, the equivalent of the transponder, with DispatcherServlet reduces the coupling between the other components.
  • HandlerMapping: Role: According to the URL request to find Handler
  • Controller: The handle user requests, which Struts Action and the role is the same. Once the user request has been processed Controller, ModelAndView DispatcherServlet object is returned to the front controller, ModelAndView contains model (Model) and the view (View).
    From a broad perspective, the controller is the DispatcherServlet entire Web application; from microscopic consideration, the Controller Http request a single process controller, and model ModelAndView Http request procedure is returned (Model) and the view (View).
  • ViewResolver view resolver: action: parsing view, a view of the logical name resolves to a real view (view)

    SpringMVC implementation process


    Flow Description:

1, the user sends a request to the front-end controller DispatcherServlet.

2, DispatcherServlet HandlerMapping call processor receives a request mapper.

3, the processor mappers find specific processor (depending on the configuration xml, notes to find), the object is generated processors and processor interceptors (if there is generated) together return to DispatcherServlet.

4, DispatcherServlet call HandlerAdapter processor adapter.

5, HandlerAdapter through specific adaptation call processor (Controller, also known as back-end).

6, Controller execute complete return ModelAndView.

7, HandlerAdapter the controller ModelAndView the results back to the DispatcherServlet.

8, DispatcherServlet ModelAndView will pass ViewReslover view resolver.

9, ViewReslover returns parsed particular View.

10, DispatcherServlet render view (model data coming filled view) The View.

11, DispatcherServlet user response.

Guess you like

Origin www.cnblogs.com/Libbo/p/11649971.html