Reputation: 5419
In my spring mvc context I have the following mappings (there is much more but this will give a general idea).
<mvc:view-controller path="/echo" view-name="echo"/>
<context:component-scan base-package="com.myapp.controllers"/>
The issue I am running into is that I have an annotated controller with @RequestMapping(value = "/e{number}"
. In the same controller with the request mapping I have a redirect the dumps the user to "home" if the @PathVariable
is not a integer.
However I do not want them to be dumped to home if they are matching the path/echo. I tried setting a <property name="order" value="0" />
on the view resolve however, without a order on the context, that is still taking priority.
How can I set priority on my component scan, or force the view-resolver to be matched first before the annotated controllers.
Upvotes: 0
Views: 577
Reputation: 7134
Having the view resolver in front of the controllers sounds like a terrible idea (if it's able to be done), particularly since the UrlBasedViewResolver (or something) and subclasses throw exceptions if they don't find a match rather than passing through the chain. If you only want the controller to step in when the path variable is an integer you should use the pattern matching option for the RequestMapping, something like /e{number:\d+}
should steer you in the right direction for a Google search.
Upvotes: 1