【SpringBoot】参数传递
1.定义URL变量
@RequestMapping("/user/{username}")
@ResponseBody
public String userProfile(@PathVariable String username){
return "user:"+username;
}
2.定义多个URL变量
@RequestMapping("/user/{username}/blog/{blogId}")
@ResponseBody
public String getUserBlog (@PathVariable String username,@PathVariable int blogId){
return "user:"+username+"blog:"+blogId;
}8
.3.匹配正则表达式
@RequestMapping("/user/{username:[a-zA-Z0-9]}/blog/{blogId}")
@ResponseBody
public String getUserBlog(@PathVariable String username,@PathVariable int blogId){
return ”user:“+username+"blog:"+blogId;
}12
原文地址:https://blog.csdn.net/wenhuakulv2008/article/details/140675651
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!