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

  • SimpleUrlHandlerMapping not matching my url

    I am using Spring 1.2.8


    <bean id="urlMapping" class="org.springframework.web.servlet.handler.Sim pleUrlHandlerMapping">
    <property name="urlMap">
    <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>

    WARN 09:01:16,182 ( -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.


    • #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.


      • #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>