0
点赞
收藏
分享

微信扫一扫

代码随想录算法训练营第44天 | 第十章 单调栈part02

非宁静不致远 2024-07-25 阅读 23

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

举报

相关推荐

0 条评论