liveBook · Manning

View resolver

As explained in Spring Start Here, Second Edition

A view resolver is a Spring MVC component that locates a view from the name returned by a controller action.

A view resolver is a Spring MVC component that finds the view named by a controller and provides its content. It handles the step between a controller returning a page name and the dispatcher servlet sending the rendered view in the HTTP response. section 7.3

For a page request, the flow is:

  • The dispatcher servlet uses the request to find a controller action. section 7.3
  • The controller returns a page name, such as home.html. section 7.3
  • The dispatcher servlet delegates finding that view’s content to the view resolver, then returns the rendered view in the response. section 7.3

A controller returning a page name

A controller action mapped to /home can return "home.html". The resolver’s role is to locate that view’s content; the dispatcher servlet uses it to produce the response. section 7.3

REST endpoints take a different path: the dispatcher servlet returns the controller’s result directly, so the flow does not use a view resolver. section 10.1

How Spring Start Here, Second Edition covers it

How deep it goes
Traces the resolver’s place in the request-to-page flow but does not describe its internal implementation.
Examples
Uses a controller mapped to /home that returns home.html as its view name.
What you can do after
Understand how a controller’s page name becomes a rendered HTTP response, and how REST responses differ.
How it connects
Connects view resolution to Spring MVC, the dispatcher servlet, controllers, and REST endpoints.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Spring Start Here, Second Edition. The section links point to the parts of the book it draws on.