Thursday, August 11, 2011

Different ways to perform Sample URL handler Mapping in Spring


Normally the SimpleUrlHandlerMapping is done inside the xxx-servlet.xml file that is inside the WEB-INF directory of your Spring project. There are different ways to do this and two ways can be described as below.


Sample

Method 1

<bean class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<value>
/account/register.jsp=flowController
</value>
</property>
<property name="alwaysUseFullPath" value="true"/>
</bean>



Method 2

<bean id="sampleMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="mappings">
<props>
<prop key ="/account/register.jsp">
flowController
</prop>
</props>
</property>
<property name="alwaysUseFullPath" value="true"/>
</bean>


flowController is an another bean id and that bean is refered whenever the relevant URL request comes.


Regards
Chathuranga Tennakoon

No comments:

Post a Comment