Spring Framework

Spring Projects

Spring Project 1

Handler Mapping in Spring MVC
Previous Home Next

Spring MVC provide the facility to handle between client request and DispatcherServlet , the DispatcherServlet provide the facility to Handler Mapping Object to map between Request and Handling Object. A Handler Mapping provide the the facility to Client's Url has to be mapped to the Handlers.

Type of Handler Mapping in Spring

The spring MVC provide the four types of handler which are map in the spring mapping file which are following:

  1. BeanNameUrlHandlerMapping
  2. CommonsPathMapHandlerMapping
  3. ControllerClassNameHandlerMapping
  4. SimpleUrlHandlerMapping


BeanNameUrlHandlerMapping: The BeanNameUrlHandlerMapping provide the facility to map the simple handler which are come from client bean object. This handler map in following types in spring configuration file:

<beans ...>
<bean name="/welcome.bean" 
class="r4r.co.controller.WelcomeController" />
<bean name="/login.bean" 
class="r4r.co.controller.LoginController" />
<bean name="/registeration.bean" 
class="r4r.co.controller.RegisterationController" />

CommonsPathMapHandlerMapping: The CommonsPathMapHandlerMapping provide the facility to the name of URL which are mapped to the controller source file for example if we are to map 'loginPage','registerationPage' and 'welcomePage' to Controllers name LoginController, RegisterationController and WelcomeController,then the mapping information allocate in meta-data in the source files inside the Javadoc comments. This handler mapping example which are following:


<bean id="metaHandlerMapping" 


ControllerClassNameHandlerMapping: This handler provide the facility to handle the more then one Handler Mapping, the Controller name using directly from the Url itself with some modifications. This handler mapping are show in the following:

<beans ...>
support.ControllerClassNameHandlerMapping" />
<bean class="r4r.co.controller.WelcomeController" />
<bean class="r4r.co.controller.HelloGuestController" />

SimpleUrlHandlerMapping: This handler provide the facility to handle more then one handler map directly to the Client Request to some Controller object. Example of this handler which are following:

<beans ...>
<bean class="org.springframework.web.servlet.
<property name="mappings">
<prop key="/welcome.bean">welcomeController</prop>
<prop key="/login.bean">loginController</prop>
<prop key="/registeration.bean">registerationController
<bean id="welcomeController" 
class="r4r.co.controller.WelcomeController" />
<bean id="loginController" 
class="r4r.co.controller.LoginController" />
<bean id="RegisterationController" 
class="r4r.co.controller.RegisterationController" />
  1. Example of BeanNameUrlHandlerMapping in Spring MVC
  2. Example of ControllerClassNameHandlerMapping in Spring MVC
  3. Example of SimpleUrlHandlerMapping in Spring MVC
Previous Home Next

Tolal:0 Click:

Show All Comments

Did not find what you were looking for leave your name and message. We will revert within 24 hours
Comment / Feedback: