PDA

View Full Version : How to redirect NON *.do URL Patterns?


sangawar
Nov 6th, 2006, 01:54 PM
Hello,

As we all know, in web.xml, we do the <servlet-mapping> for *.do patterns
as shown below:

<!-- Spring MVC intercepts all URLs with '.do' extension -->
<servlet-mapping>
<servlet-name>myProj</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>

I also added another <servlet-mapping> to a case where the pattern
is not *.do.

<!-- The next three are special mappings for the profile functionality -->

<servlet-mapping>
<servlet-name>myProj</servlet-name>
<url-pattern>/xyz/*</url-pattern>
</servlet-mapping>

Here are my questions:

1. In myProj-servlet.xml, I have the following:
<!-- All requests mapped in web.xml come here first -->
<bean id="urlMapping"
class="org.springframework.web.servlet.handler.SimpleUrlH andlerMapping">
<property name="mappings">
<props>
<prop
key="/static.do">staticContentController</prop>
<prop key="/help.do">helpController</prop>
etc.

2. I tried to put the following as part of the bean id mentioned in item 1
<prop
key="/xyz/*">someController</prop>

It is not going to someController when I put the following in my browser:
http://localhost:8080/xyz/abcd.

3. Am I supposed to create another bean id similar to the one mentioned in
item 1 above?

Can some kind soul explain the steps clearly so that it works.

Greatly appreciate your help on this...

Pramod

Olivier Hermans
Nov 6th, 2006, 04:08 PM
The url pattern of a handler mapping is relative to the url pattern specified in your web.xml. You can set the alwaysUseFullPath property of your SimpleUrlHandlerMapping bean to true to make your example work.

sangawar
Nov 8th, 2006, 10:57 AM
Thanks and that hint fixed our issue.

Pramod