HandlerMapping is an Interface to be implemented by objects that define a mapping between requests and handler objects. By default DispatcherServlet uses BeanNameUrlHandlerMapping and DefaultAnnotationHandlerMapping. In Spring we majorly use the below handler mappings
- BeanNameUrlHandlerMapping
- ControllerClassNameHandlerMapping
- SimpleUrlHandlerMapping
Spring MVC BeanNameUrlHandlerMapping Example
In BeanNameUrlHandlerMapping in this article. Here we will be mapping each request to a Bean directly.
Spring MVC ControllerClassNameHandlerMapping Example
ControllerClassNameHandlerMapping uses a convention to map the requested URL to the Controller. It will take the Controller name and converts them to lower case with a leading “/”
Spring MVC SimpleUrlHandlerMapping Example
SimpleUrlHandlerMapping is the simplest of all handler mappings which allows you specify URL pattern and handler explicity