SpringMVC overview and principle

Spring MVC features:

  1. Lightweight, easy to learn
  2. Efficient, MVC-based request response frame
  3. Spring and compatibility, and seamless integration
  4. Convention over configuration
  5. Powerful: RESTful, data validation, formatting, localization, themes, etc.
  6. Simple and flexible
    The most important thing is with more people, companies use more. . .

SpringMVC major components

1. The central controller: DispatcherServlet

  • [] Servlet scheduling is a scheduling function Servlet, when initiating the intercepted request upstream to request controller generates a proxy request depending on the request, and then requests distributed to different processors, and then further processed by the processor .
  • Spring MVC framework, like many other MVC frameworks, request-driven around a center Servlet dispatch requests and provide other functions, DispatcherServlet is an actual Servlet (it inherits from HttpServlet base class ).
    enter description here

2. Processor Mapper

Responsible for handling URL, and find the corresponding processor, then sent to the processor adapter

3. Processor Adapter

Specific methods mapper handles requests sent and maps it to the controller

4. view resolver

After the finish control business operations, it will return a "ModelAndView", which will contain the necessary data model, and page resources address. View resolver is responsible for receiving data, and then processed:

  1. Stitching complete resource path, such as: / WEB-INF / jsp + name + .jsp page
  2. After rendering the page is sent back to DispatcherServlet

SpringMVC implementation of the principle of

Implementation process

  1. It represents DispatcherServlet front controller, the whole SpringMVC control center. Requesting user, DispatcherServlet receives the request and interception request.
    We assume that the request url is: HTTP: // localhost: 8080 / SPRINGMVC / Hello as url split into three parts:

    • http: // localhost: 8080 Server domain
    • SpringMVC deployed on the server's web site name
    • hello indicates that the controller

    Analysis, as described above url: Request a server located localhost: hello controller on site SpringMVC 8080.

  2. HandlerMapping played: DispatcherServlet call HandlerMapping, HandlerMapping url look Handler upon request.

  3. HandlerExecution shows a specific Handler, its main role is to find a controller according to url, url be searched as controller: hello.
    HandlerExecution transmitting the analysis information to DispatcherServlet, mapping controller resolver.

  4. HandlerAdapter adapter indicates that the processor, which performs Handler to specific rules.

  5. Handler let specific Controller to perform: Business Operations
    Controller will execute specific information (such as ModelAndView) returned to HandlerAdapter.

  6. The view logic HandlerAdapter or model name passed to DispatcherServlet.

  7. DispatcherServlet call the view resolver (ViewResolver) to resolve the logical view name HandlerAdapter transfer.

  8. View resolver resolves the logical view name passed DispatcherServlet.
    According DispatcherServlet view results view parser, call the specific view.

  9. The final view will be presented to the user

Guess you like

Origin www.cnblogs.com/ggyzzz/p/12609295.html