How Do You Configure Spring MVC @PathVariables to Accept Strings Containing Dashes?
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.
开发者_StackOverflow中文版Thanks.
I just tested that with my spring-mvc 3.0.5 application and it works fine with a dash:
- make sure you are running the latest version
- make sure you are tracking the correct request (and not some fake one, for example a forgotten ajax request)
 
         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论