Building web applications with Spring MVC

Spring moves requests around between a dispatcher servlet, handler mappings, controllers, and view resolvers.


But a typical application may have several controllers and DispatcherServlet needs some help deciding which controller to send the request to. So the DispatcherServlet consults one or more handler mappings to figure out where the request’s next stop will be.

The logic performed by a controller often results in some information that needs to be carried back to the user and displayed in the browser. This information is referred to as the model. But sending raw information back to the user isn’t sufficient—it needs to be formatted in a user-friendly format, typically HTML. For that the information needs to be given to a view, typically a JSP.

The DispatcherServlet will consult a view resolver to map the logical view name to a specific view implementation, which may or may not be a JSP.

One of the last things that a controller does is package up the model data and identify the name of a view that should render the output.

Now that DispatcherServlet knows which view will render the result, the request’s job is almost over. Its final stop is at the view implementation (probably a JSP) where it delivers the model data. The request’s job is finally done. The view will use the model data to render output that will be carried back to the client by the (not-so-hardworking) response object.