Spring MVC SimpleUrlHandlerMapping example

In Spring MVC application, the SimpleUrlHandlerMapping is the most flexible handler mapping class, which allow developer to specify the mapping of URL pattern and handlers explicitly. The SimpleUrlHandlerMapping can be declared in two ways. 1. Method 1 – prop key The property keys are the URL patterns while the property values are the handler IDs …

Read more

Spring MVC BeanNameUrlHandlerMapping example

In Spring MVC, BeanNameUrlHandlerMapping is the default handler mapping mechanism, which maps URL requests to the name of the beans. For example, <beans …> <bean class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/> <bean name="/welcome.htm" class="com.mkyong.common.controller.WelcomeController" /> <bean name="/streetName.htm" class="com.mkyong.common.controller.StreetNameController" /> <bean name="/process*.htm" class="com.mkyong.common.controller.ProcessController" /> </beans> In above example, If URI pattern /welcome.htm is requested, DispatcherServlet will forward the request to the …

Read more