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

阅读 24

2024-07-25

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)

0 0 举报