@ExceptionHandler
注解可以和注解@RestControllerAdvice
(或@ControllerAdvice
)组合使用,构建Spring MVC架构中全局异常处理机制。
package org.springframework.web.bind.annotation;
@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface ExceptionHandler {
Class<? extends Throwable>[] value() default {};
}