@pathvariable啥作用
时间: 2023-09-25 07:15:06 浏览: 85
@PathVariable的作用是将URL中的占位符参数绑定到控制器的方法进行入参。通过使用@Pathvariable("XXX")注解,可以将URL中的{XXX}占位符参数绑定到对应的方法参数上。一般在GET请求中使用。 例如,使用@GetMapping("list/{page}/{limit}")定义了一个URL路径,可以通过@Pathvariable(value="page")和@Pathvariable(value="limit")将"page"和"limit"这两个占位符参数绑定到方法的参数上。另外,当参数名称和URL中变量名称一致时,还可以简写为@RequestParam("/do/{id}") public String Emp(@PathVariable Integer id)。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [@pathvariable注解的作用](https://blog.csdn.net/qqw666666/article/details/125412156)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* [@PathVariable注解的作用](https://blog.csdn.net/y516369/article/details/127433946)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文