his is an example of how to handle URL requests mapping in Spring MVC. In particular, we shall check on three handler mapping classes that Spring MVC provides for handling URL requests. They are all used to define a mapping between URL requests and handler objects. We will create a simple project with a Controller, a view (jsp) and we will add the necessary configuration files, and then we will use an application server to run the example, making use of all handler mapping classes.
The BeanNameUrlHandlerMapping class maps URL requests to beans names. It is the default handler mapping class, so it is the one created by the DispatcherServlet when Spring cannot find any handler mapping class declared. An example of using the BeanNameUrlHandlerMapping class is shown below. There are two beans declared, the first one’s name is helloWorld.htm and its class is the HelloWorldController. So the BeanNameUrlHandlerMapping will map any helloWorld URL request to this Controller. The second bean’s name is the hello*.htm and its class is also the HelloWorldController. So, in this case, the BeanNameUrlHandlerMapping will map any URL request that starts with hello (such as helloWorld, helloAll) to the HelloWorldController.