@ModelAttribute和@RequestBody和共存
时间: 2023-10-27 19:00:13 浏览: 84
浅析@ReponseBody和@RequestBody注解
当@ModelAttribute和@RequestBody同时存在时,@ModelAttribute注解将会被忽略,只有@RequestBody注解起作用。@ModelAttribute注解主要用于将方法的返回值绑定到具体的Model上,而@RequestBody注解用于将请求的内容绑定到方法的参数上,因此它们的作用是不同的。在同时使用时,@RequestBody注解会覆盖@ModelAttribute注解的效果。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [【技术面试】Java八股文业余选手-上篇(持续更新)](https://blog.csdn.net/niaonao/article/details/131865099)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
- *2* *3* [Spring相关注解](https://blog.csdn.net/zhanjin1989/article/details/125514141)[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^v93^chatsearchT3_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文