use*_*920 20 java spring annotations path-variables spring-mvc
遗憾的是找不到答案,所以希望有人可以提供帮助.
在Spring MVC 3.1.0中,这是我的方法:
@RequestMapping(value = "/{app}/conf/{fnm}", method=RequestMethod.GET)
public ResponseEntity<?> getConf(@PathVariable String app, @PathVariable String fnm) {
log.debug("AppName:" + app);
log.debug("fName:" + fnm);
...
return ...
}
Run Code Online (Sandbox Code Playgroud)
我在网上看过一些例子,看起来理论上有多个@PathVariables没问题.
但是,当我这样做时,"app"和"fnm"都包含相同的值(这是分配给"app"的任何值).
真的很感激有人可能对我出错的地方有任何见解?
谢谢!
ace*_*es. 31
@RequestMapping(value = "/{app}/conf/{fnm}", method=RequestMethod.GET)
public ResponseEntity<?> getConf(@PathVariable("app") String app, @PathVariable("fnm") String fnm) {
log.debug("AppName:" + app);
log.debug("fName:" + fnm);
...
return ...
}
Run Code Online (Sandbox Code Playgroud)
基本上路径变量需要在方法参数中用括号指定.这有帮助吗?