当前位置 : 主页 > 编程语言 > python >

@RequestMapping接口动态参数

来源:互联网 收集:自由互联 发布时间:2023-03-22
1.单参数接收 @RequestMapping(value = "/v1/{cate}",method = RequestMethod.GET)public String dynApiDemo2(@PathVariable("cate")String cate){ String cateUrl = map.get("cate"); return "v1/"+cateUrl;} 2.多参数Map接收 @RequestMapping(val

1.单参数接收

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

2.多参数Map接收

@RequestMapping(value = "/{version}/{cate}/{article}",method = RequestMethod.GET)public String dynApiDemo(@PathVariable Map<String, String> map){ String version = map.get("version"); String cateUrl = map.get("cate"); String articleUrl = map.get("article"); return version+"/"+cateUrl+"/"+articleUrl;}

3.正则接收

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

如果本文帮到你了,欢迎关注本人公众号:周三想吧

@RequestMapping接口动态参数_接口动态参数

上一篇:java 字符串拼装
下一篇:没有了
网友评论