spring 全局异常处理
生活随笔
收集整理的這篇文章主要介紹了
spring 全局异常处理
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
例子:
@RestControllerAdvice public class RestException {//可處理運行時異常@ExceptionHandler({RuntimeException.class})@ResponseStatus(HttpStatus.UNAUTHORIZED)public String handleRuntimeException(){return "asdasd";}//可處理編譯時異常@ExceptionHandler({Exception.class})public ResponseEntity handleException(Exception ex) {return new ResponseEntity("Exasdception",HttpStatus.UNAUTHORIZED);} }?
轉載于:https://www.cnblogs.com/liuboyuan/p/8583359.html
總結
以上是生活随笔為你收集整理的spring 全局异常处理的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 常用 SQL 语句汇总
- 下一篇: 如何在SAP CRM WebClient