如何更改动态网址的请求映射。 URL可能如下所示:
是工作控制器语法:
http://zz.zz.zz.com:8080/webapp/test?Id=2&maxrows=5
@RequestMapping(value = "/test", method = RequestMethod.GET)
public @ResponseBody
void test(@RequestParam(value = "Id", required = true) String Id,
@RequestParam(value = "maxrows", required = true) int maxrows)
throws Exception
{
System.out.println("Id: " + Id + " maxrows: " + maxrows);
}
答案 0 :(得分:2)
试试这个:
@RequestMapping(value = "/test/{param1}/{param2}/{param3}")
public @ResponseBody void test(
@RequestParam(value = "Id", required = true) String Id,
@RequestParam(value = "maxrows", required = true) int maxrows,
@PathVariable(value = "param1") String param1,
@PathVariable(value = "param2") String param2,
@PathVariable(value = "param3") String param3) {
...
}
有关详细信息,请查看Spring Reference Documentation