Announcement Announcement Module
Collapse
No announcement yet.
SimpleUrlHandlerMapping not matching my url Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • SimpleUrlHandlerMapping not matching my url

    I am using Spring 1.2.8

    <servlet-mapping>
    <servlet-name>myproject</servlet-name>
    <url-pattern>/a/*</url-pattern>
    </servlet-mapping>


    <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="urlMap">
    <map>
    <entry key="/a/00000000/"><ref local="myController"/></entry>
    <entry key="/a/00000001"><ref local="myController"/></entry>
    <entry key="/a/foo"><ref local="myController"/></entry>
    <entry key="/a/*"><ref local="myController"/></entry>
    <entry key="/a/**"><ref local="myController"/></entry>
    <entry key="/a/**/*"><ref local="myController"/></entry>
    <entry key="/help"><ref local="myController"/></entry>
    </map>
    </property>
    </bean>

    WARN 09:01:16,182 (DispatcherServlet.java:noHandlerFound:833) -No mapping for [/MyContext/a/00000000/foo] in DispatcherServlet with name 'myproject'


    I am trying to forward all requests to /a/* to myController, as per the <servlet-mapping>.


    From what I understand:

    Tomcat is doing the correct thing and getting the request to Spring's dispatcher, since the WARN log entry is emitted.
    But of the entries listed above only "/help" works correctly.
    I also find that "/a" works as well (but it is not a useful URL for me, since myController makes use of the path details from the URL, hence why I want /a/** match).
    Nothing prefixed with "/a/" works. Not even "/a/foo". When I say does not work, I mean I get back a HTTP 404 and no method on myController is invoked.

    Any suggestions what I am doing wrong ?

  • #2
    Try removing the /a prefix in your url mappings.

    Comment


    • #3
      Originally posted by devijvers
      Try removing the /a prefix in your url mappings.
      Thanks for the reply. But... when I create the /b/ hierachy (which is my next step once this is working) I want /b/foo to go to a different controller.

      So if the mapping is just:

      <entry key="foo"><ref local="myController"/></entry>

      How could it map /a/foo and /b/foo independantly.

      Comment


      • #4
        Ah ha, found this property nugget "alwaysUseFullPath" problem appears solved.

        <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
        <property name="alwaysUseFullPath"><value>true</value></property>
        ...
        </bean>

        Comment

        Working...
        X