liveBook · Manning

Handler mapping

As explained in Spring Start Here, Second Edition

A handler mapping is a Spring MVC component that selects a controller action for an incoming request based on request conditions such as path and HTTP method.

A handler mapping finds which controller action should handle an incoming request. The DispatcherServlet delegates this lookup to it, using the action’s @RequestMapping; if no action matches, the app responds with HTTP 404 Not Found. section 7.3

Mapping a home page

A controller action annotated with @RequestMapping("/home") is associated with requests to /home. The handler mapping finds the action, and the DispatcherServlet calls it. section 7.3

Figure 7.18 The Spring MVC architecture. In the diagram, you find the main components of Spring MVC. These components and the way they collaborate are responsible for a web app’s behavior. The controller (shaded differently) is the only component you implement. Spring Boot configures the other components.

See where the handler mapping fits among the components that collaborate to handle a web request. section 7.3

How Spring Start Here, Second Edition covers it

How deep it goes
Explains lookup by @RequestMapping and notes HTTP methods, deferring their detail.
Examples
Uses a controller action mapped to /home with @RequestMapping.
What you can do after
Understand how a request is matched to a controller action and when an unmatched request returns 404.
How it connects
Connects the DispatcherServlet, controller actions, and @RequestMapping.

Also explained in

Compare how 2 books explain handler mapping →

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.