Given the following request mapping on a Spring MVC controller:
@RequestMapping(method=GET, value="/users/{name}")
ModelAndView findUser(@PathVariable String name) {
...
}
How can I make it accept a @PathVariable with a dash in it?
The following works, passing in fred as the name:
GET /users/fred
However the following does not work, passing in null in place of the name:
GET /users/u-fred
I would appreciate suggestions on how to define the @PathVariable so it can accept dashed strings, for example, u-fred.
Thanks.
@InitBinderthat will cause this problem? A string with dash(es) in it works fine for me, I use it a lot in my projects.