【发布时间】:2017-06-28 08:20:13
【问题描述】:
我正在寻找一种将多个路径参数用作一个字符串的方法。
下面的映射很清楚:它定义了3个静态参数作为路径变量:
@RequestMapping(value = "/rest/{language}/{country}/{term}?someparams=test&...", method = RequestMethod.GET)
但我希望将/rest 和{term} 之间的任何内容写入一个@PathVariable`。
例如:我可以打电话给localhost:8080/rest/this/is/my/dynamic/customterm?someparams)...
在这里,我想将/this/is/my/dynamic 作为一个单一的路径变量。
以下不起作用:
@RequestMapping(value = "/rest/{multiplePathParams}/{term}someparams=test&...", method = RequestMethod.GET)
public void test(@PathVariable String multiplePathParams, @PathVariableString term) {
Assert.assertEquals(multiplePathParams, "/this/is/my/dynamic");
Assert.assertEquals(term, "customterm");
}
有可能吗?
【问题讨论】:
标签: java spring rest spring-mvc