views:

89

answers:

2

I have a controller with @RequestMapping for root path "/". There are other controllers with say a @RequestMapping of "/test" etc. My application seems to be mapping correctly for paths like /appname/test, but if I add a trailing slash to the path, like so "/appname/test/ then it maps to the controller that has the @RequestMapping for root path "/". Any idea why?

Update:

I also tried removing <mvc:annotation-driven /> and replacing with

<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"
   p:order="0" p:alwaysUseFullPath="true" /> 
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter" 
   p:alwaysUseFullPath="true"/> 

That fixed the trailing slash problem, but my validations stopped working

+1  A: 

Looks like a bug (SPR-7064), fixed in 3.0.3, should be out soon.

skaffman
hmm, wondering how petclinic sample works okay! It was built with 3.0.0. My app is on 3.0.2, maybe I will go back to 3.0.0
Eqbal
@Eqbal: Alternatively, you could add more path mappings as a workaround. `@RequestMapping` can take multiple paths.
skaffman
That does not work, anything with a trailing slash maps to root.
Eqbal