NOTE

2.7 Introduction

Spring MVC components and request-processing flow.

JavaCreated Updated 1 min readhistorical

This is a historical learning note and may contain outdated or incomplete understanding.

Components

Core: DispatcherServlet.

Three major components: HandlerMapping, HandlerAdapter, ViewResolver.

Written by the user: Handler, View.

Flow

  1. The user sends a request to the front controller DispatcherServlet.
  2. After receiving the request, DispatcherServlet calls the HandlerMapping handler mapper.
  3. The handler mapper finds the specific handler according to the request URL, creates the handler object and handler interceptor (if any), and returns them together to DispatcherServlet.
  4. DispatcherServlet invokes the handler through the HandlerAdapter.
  5. Execute the handler (Controller, also called the backend controller).
  6. After execution, the Controller returns ModelAndView.
  7. HandlerAdapter returns the Controller execution result ModelAndView to DispatcherServlet.
  8. DispatcherServlet passes ModelAndView to the ViewResolver.
  9. After resolution, ViewResolver returns the specific View.
  10. DispatcherServlet renders the View (that is, fills the model data into the view).
  11. DispatcherServlet responds to the user.

Discussion

Sign in with GitHub to comment. Discussions are stored as GitHub Issues.View on GitHub