[英]Multiple @PathVariable in 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 ...
}
我在网上看过一些例子,看来理论上有多个@PathVariables没问题。
但是当我这样做时,“app”和“fnm”都包含相同的值(这是分配给“app”的任何值)。
真的很感激有人可能对我出错的地方有任何见解?
谢谢!
@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 ...
}
基本上路径变量需要在方法参数中用括号指定。 这有帮助吗?
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.