@PathVariable注解的使用
时间: 2023-08-26 21:17:04 浏览: 122
获取Spring中@PathVariable注解里带点的完整参数.doc
@PathVariable注解用于将URL中的占位符参数绑定到控制器处理方法的入参中。一般与@RequestMapping(method = RequestMethod.GET)一起使用。通过在@RequestMapping注解中指定占位符的名称,再在@PathVariable注解中指定对应的参数名称,可以将URL中的占位符参数绑定到方法的入参中。这样,在请求"/getUserById/John"时,方法的入参name将会自动被赋值为"John",可以在方法体中使用这个参数进行相应的逻辑处理。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [@PathVariable注解的用法](https://blog.csdn.net/weixin_45055846/article/details/118783880)[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/qq_41451744/article/details/125765587)[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 ]
阅读全文