Announcement Announcement Module
Collapse
No announcement yet.
How to redirect NON *.do URL Patterns? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to redirect NON *.do URL Patterns?

    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.Sim pleUrlHandlerMapping">
    <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
    Last edited by sangawar; Nov 6th, 2006, 01:56 PM. Reason: How to redirect NON *.do URL Patterns?

  • #2
    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.
    Last edited by Olivier Hermans; Nov 6th, 2006, 04:55 PM.

    Comment


    • #3
      Thanks and that hint fixed our issue.

      Pramod

      Comment

      Working...
      X