我现有的代码如下:
@RequestMapping(value = "/{id}/{type}/{answer}", method = RequestMethod.GET)
@ResponseBody
public Results answer(@PathVariable("id") int questionId,
@PathVariable int type,
@PathVariable Boolean answer) {
//do something
}
我希望能够添加使用任意数量的路径变量发出请求的功能,但保持与上述相同的模式(即 /id/type/answer/id/type/answer/id/type/answer/. ..ETC。)。
因此,理想情况下,我希望能够创建一个支持以下两个 URL 的 API 调用:
http://www.example.com/sendAnswer/id1/typeA/0
和
http://www.example.com/sendAnswer/id1/typeA/0/id2/typeB/1/id3/typeA/0
有没有人有任何想法?