@RequestMapping接口动态参数

知识的领域是无限的,我们的学习也是无限期的。这篇文章主要讲述@RequestMapping接口动态参数相关的知识,希望能为你提供帮助。
1.多参数Map接收


1 @RequestMapping(value = "https://www.songbingjia.com/{version}/{cate}/{article}",method = RequestMethod.GET) 2 public String dynApiDemo(@PathVariable Map< String, String> map){ 3String version = map.get("version"); 4String cateUrl = map.get("cate"); 5String articleUrl = map.get("article"); 6return version+"/"+cateUrl+"/"+articleUrl; 7 }


 
2.单参数接收


@RequestMapping(value = "https://www.songbingjia.com/v1/{cate}",method = RequestMethod.GET) public String dynApiDemo2(@PathVariable("cate")String cate){ String cateUrl = map.get("cate"); return "v1/"+cateUrl; }

 
3.正则接收


@RequestMapping(value = "https://www.songbingjia.com/regexp/{name:/w}",method = RequestMethod.GET) public String dynApiDemo3(@PathVariable("name")String name){ System.out.println(name); return ""; }

 
【@RequestMapping接口动态参数】



    推荐阅读