1.多参数Map接收
1 @RequestMapping(value = "/{version}/{cate}/{article}",method = RequestMethod.GET) 2 public String dynApiDemo(@PathVariable Map<String, String> map){ 3 String version = map.get("version"); 4 String cateUrl = map.get("cate"); 5 String articleUrl = map.get("article"); 6 return version+"/"+cateUrl+"/"+articleUrl; 7 }
2.单参数接收
@RequestMapping(value = "/v1/{cate}",method = RequestMethod.GET) public String dynApiDemo2(@PathVariable("cate")String cate){ String cateUrl = map.get("cate"); return "v1/"+cateUrl; }
3.正则接收
@RequestMapping(value = "/regexp/{name:\w}",method = RequestMethod.GET) public String dynApiDemo3(@PathVariable("name")String name){ System.out.println(name); return ""; }