Exact RequestMapping with Spring
java, spring
Solution
Turning off suffix matching (`useSuffixPatternMatch`) on `RequestMappingHandlerMapping` will solve your problem, but doing so is actually not so easy, if you use `<mvc:annotation-driven/>` in your configuration (instead of manually wiring all the necessary infrastructure beans). In this case defining an additional bean of type `RequestMappingHandlerMapping` won't have any effect.
You have two options:
Remove `<mvc:annotation-driven/>` expanding it to an equivalent set of bean definitions where you can apply the `useSuffixPatternMatch` setting.
Keep `<mvc:annotation-driven/>` as it is, and use a much easier workaround described here: https://jira.springsource.org/browse/SPR-9371. This basically adds a `BeanPostProcessor` which retrieves the `RequestMappingHandlerMapping` bean created by the mvc namespace, and sets the above mentioned flag.
There is also another ticket requesting that it should be much easier to customize the `RequestMappingHandlerMapping` created by the mvc namespace without applying hacks like above. You can consider voting on this ticket.
Problem
I have the following in Spring ``` @RequestMapping("/hello") ``` However Spring automatically adds mappings for /hello/ as well as /hello.*. How do I do an exact URL match? Only /hello should work, anything else should 404