Fresh off my last adventure, now I'm trying to map more complex URLs and going nuts trying to make it work the way Spring's documentation suggests it should.
Again, the tools are:
- Java 1.6
- Spring 3.2 MVC
- Tomcat 7
What I'm trying to do is match URLs of the form foo/bar/id where id is an integer. The way it seems like I should do it is to annotate my controller method like this:
@RequestMapping("/foo/bar/{id}")
And then have this in web.xml:
<url-filter>/foo/*</url-filter>
Or this:
<url-filter>/foo/bar/*</url-filter>
And then after deploying to Tomcat, I should be able to access /mycontext/foo/bar/id. But that doesn't work.
For completeness, here several variations and results:
- Method mapping: /foo, url-filter: /foo, result: /mycontext/foo works.
- Method mapping: /foo/*, url-filter: /foo/*, result: successful mapping of method to /foo/* reported at deployment, but accessing /mycontext/foo/bar fails.
- Method mapping: /foo/*, url-filter: /foo/bar, result: mapped at deployment, but accessing /mycontext/foo/bar fails.
- Method mapping: /foo/bar, url-filter: /foo/bar, result: /mycontext/foo/bar works.
- Method mapping: /foo/bar/*, url-filter: /foo/bar/*, result: mapped at deployment, but accessing /mycontext/foo/bar/(anything) fails.
- Method mapping: /foo/bar/{id}, url-filter: /foo/bar/*, result: mapped at deployment, but accessing /mycontext/foo/bar/(anything) fails.
All of the failures come with error messages from the DispatcherServlet for mycontext that no mapping was found, even though all of them reported success in setting up mapping at deployment time. Since I'm getting the error from the right DispatcherServlet, that suggests my url-filter settings are fine. But the message about successful mapping at deployment references whatever is in the @RequestMapping annotation, so I don't know what to make of Spring first saying it's fine and then later saying it doesn't match.
Is there something I've failed to understand about wildcards here?