[Spring MVC] 1 Spring MVC Introduction

Outline

Spring MVC also known as Spring Web MVC, belonging to the presentation layer framework. SpringMVC part of the Spring Framework.

Spring Web MVC framework provides a MVC (Model - View - Controller) architecture for flexible and loosely coupled components to develop Web applications. MVC pattern leads to different aspects of the application (input logic, business logic and UI logic) separation, while providing a loose coupling between these elements.

  • Model (Model): encapsulates application data, they will typically POJO classes.
  • View (View): is responsible for rendering the model data, in general, it can generate client browser interprets the HTML output.
  • A controller (Controller): responsible for handling user requests and construct appropriate models and passes it to render the view.

DispatcherServlet component class

Spring Web MVC framework is designed around DispatcherServlet, which handles all of the HTTP requests and responses.

Spring Web MVC DispatcherServlet request processing flow as shown below:
1
The following sequence of events corresponding to the incoming HTTP requests DispatcherServlet:

  • Upon receiving the HTTP request, DispatcherServlet HandlerMapping queries to invoke the appropriate Controller.
  • Controller accepts the request and calls the appropriate service method using the GET or POST method. The method of business logic services provided based on the data model definition, and returns the name of the view to the DispatcherServlet.
  • DispatcherServlet from ViewResolver get custom view of the request.
  • When the view is completed, DispatcherServlet to transfer model data to its final view, and presented on the browser.

All of the above components, namely: HandlerMapping, Controller and ViewResolver is part of WebApplicationContext, it is an extension of ordinary ApplicationContext, with some additional functionality needed for Web applications.

Guess you like

Origin www.cnblogs.com/xiaofengwang/p/11236037.html