Spring MVC中的多个@PathVariable [英] Multiple @PathVariable in Spring MVC
问题描述
无法找到一个答案不幸所以希望有人可以提供帮助。
在Spring MVC中3.1.0这里是我的方法:
@RequestMapping(值=/ {}应用程序/ conf目录/ {} FNM,方法= RequestMethod.GET)
公共ResponseEntity<>在getconf(@PathVariable字符串的应用程序,@PathVariable字符串FNM){
log.debug(APPNAME:+应用程序);
log.debug(FNAME:+ FNM);
...
返回...
}
我见过一些在线的例子,它似乎存在具有理论上多个@PathVariables没有问题的。
然而,当我这样做,既应用和FNM包含相同的值(这是任何值被分配到应用程序)。
真的AP preciate任何见解有人可能要我要去哪里错了?
谢谢!
@RequestMapping(值=/ {}应用程序/ conf目录/ {} FNM,方法= RequestMethod.GET)
公共ResponseEntity<>在getconf(@PathVariable(应用程序)字符串的应用程序,@PathVariable(FNM)字符串FNM){
log.debug(APPNAME:+应用程序);
log.debug(FNAME:+ FNM);
...
返回...
}
基本上路径变量需要使用括号中指定,方法参数。
这是否帮助?
Couldn't find an answer to this unfortunately so hoping someone can help.
In Spring MVC 3.1.0 here is my method:
@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 ...
}
I've seen some examples online and it appears there is no problem having multiple @PathVariables in theory.
However when I do it, both "app" and "fnm" contain the same value (which is whatever value was assigned to "app").
Really appreciate any insight someone may have to where I'm going wrong?
Thanks!
@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 ...
}
Basically path variables need to be specified with parentheses, in method arguments. Does this help?
这篇关于Spring MVC中的多个@PathVariable的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!