@restcontroller有什么作用
时间: 2023-09-27 14:07:55 浏览: 65
@RestController注解是一个组合注解,相当于@Controller注解和@ResponseBody注解的组合。该注解用于标识一个类是一个Controller类,并且该类中的所有方法都会默认添加@ResponseBody注解,表示返回的结果直接作为响应体返回给客户端。@RestController注解常用于构建RESTful风格的接口,可以方便地将方法的返回值转换为JSON或XML等格式进行返回。所以,@RestController注解的作用是将一个类标识为Controller类,并且使类中的所有方法的返回值直接作为响应体返回给客户端。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [接口开发相关知识点?@RestController注解和@Api注解是什么意思?有什么用?](https://blog.csdn.net/qq_20446879/article/details/100109353)[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* [@RestController的作用](https://blog.csdn.net/lolichan/article/details/84915044)[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 ]
阅读全文