publicResponseEntity<ErrorResponse> handleException(Exception ex) { ErrorResponse error =newErrorResponse(HttpStatus.INTERNAL_SERVER_ERROR, ex.getMessage()); returnnewResponseEntity<>(error, HttpStatus.INTERNAL_SERVER_ERROR); } } 在上述代碼中,@ControllerAdvice 標注的類表明這是一個全局異常處理類,@Except...
www.dbjr.com.cn/program/3046008...htm 2025-5-28