Handler mapping
We have learned that DispatcherServlet
is the one that dispatches the request to the handler methods based on the request mapping; however, in order to interpret the mappings defined in the request mapping, DispatcherServlet
needs a HandlerMapping
implementation (org.springframework.web.servlet.HandlerMapping
). The DispatcherServlet
consults with one or more HandlerMapping
implementations to find out which controller (handler)
can handle the request. So, HandlerMapping
determines which controller to call.
The HandlerMapping
interface provides the abstraction for mapping requests to handlers. The HandlerMapping
implementations are capable of inspecting the request and coming up with an appropriate controller. Spring MVC provides many HandlerMapping
implementations, and the one we are using to detect and interpret mappings from the @RequestMapping
annotation is the RequestMappingHandlerMapping
class (org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping...