@RestControllerAdvice什么作用
时间: 2023-10-27 14:25:26 浏览: 121
@RestControllerAdvice注解是一个用于定义全局RESTful异常处理类的类级别注解。通过使用@RestControllerAdvice和@ExceptionHandler注解,你可以实现在整个应用程序范围内统一处理RESTful风格的异常。它自动将异常处理方法的返回值转换为HTTP响应的主体,使得代码更加简洁、可读和可维护。与@ControllerAdvice注解相比,@RestControllerAdvice注解继承了@ControllerAdvice注解的属性annotations,并且专门用于处理RESTful风格的异常。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *2* *3* [@RestControllerAdvice注解](https://blog.csdn.net/jiayoudangdang/article/details/130473316)[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_2"}}] [.reference_item style="max-width: 100%"]
[ .reference_list ]
阅读全文