|
|
|
@ -1,5 +1,5 @@ |
|
|
|
/* |
|
|
|
/* |
|
|
|
* Copyright 2002-2018 the original author or authors. |
|
|
|
* Copyright 2002-2019 the original author or authors. |
|
|
|
* |
|
|
|
* |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
* you may not use this file except in compliance with the License. |
|
|
|
@ -46,16 +46,16 @@ import org.springframework.stereotype.Component; |
|
|
|
* <p>Note: For {@code @ExceptionHandler} methods, a root exception match will be |
|
|
|
* <p>Note: For {@code @ExceptionHandler} methods, a root exception match will be |
|
|
|
* preferred to just matching a cause of the current exception, among the handler |
|
|
|
* preferred to just matching a cause of the current exception, among the handler |
|
|
|
* methods of a particular advice bean. However, a cause match on a higher-priority |
|
|
|
* methods of a particular advice bean. However, a cause match on a higher-priority |
|
|
|
* advice will still be preferred to a any match (whether root or cause level) |
|
|
|
* advice will still be preferred over any match (whether root or cause level) |
|
|
|
* on a lower-priority advice bean. As a consequence, please declare your primary |
|
|
|
* on a lower-priority advice bean. As a consequence, please declare your primary |
|
|
|
* root exception mappings on a prioritized advice bean with a corresponding order! |
|
|
|
* root exception mappings on a prioritized advice bean with a corresponding order. |
|
|
|
* |
|
|
|
* |
|
|
|
* <p>By default the methods in an {@code @ControllerAdvice} apply globally to |
|
|
|
* <p>By default, the methods in an {@code @ControllerAdvice} apply globally to |
|
|
|
* all Controllers. Use selectors {@link #annotations()}, |
|
|
|
* all controllers. Use selectors {@link #annotations}, |
|
|
|
* {@link #basePackageClasses()}, and {@link #basePackages()} (or its alias |
|
|
|
* {@link #basePackageClasses}, and {@link #basePackages} (or its alias |
|
|
|
* {@link #value()}) to define a more narrow subset of targeted Controllers. |
|
|
|
* {@link #value}) to define a more narrow subset of targeted controllers. |
|
|
|
* If multiple selectors are declared, OR logic is applied, meaning selected |
|
|
|
* If multiple selectors are declared, boolean {@code OR} logic is applied, meaning |
|
|
|
* Controllers should match at least one selector. Note that selector checks |
|
|
|
* selected controllers should match at least one selector. Note that selector checks |
|
|
|
* are performed at runtime and so adding many selectors may negatively impact |
|
|
|
* are performed at runtime and so adding many selectors may negatively impact |
|
|
|
* performance and add complexity. |
|
|
|
* performance and add complexity. |
|
|
|
* |
|
|
|
* |
|
|
|
@ -98,8 +98,8 @@ public @interface ControllerAdvice { |
|
|
|
String[] basePackages() default {}; |
|
|
|
String[] basePackages() default {}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Type-safe alternative to {@link #value()} for specifying the packages |
|
|
|
* Type-safe alternative to {@link #basePackages} for specifying the packages |
|
|
|
* to select Controllers to be assisted by the {@code @ControllerAdvice} |
|
|
|
* in which to select controllers to be advised by the {@code @ControllerAdvice} |
|
|
|
* annotated class. |
|
|
|
* annotated class. |
|
|
|
* <p>Consider creating a special no-op marker class or interface in each package
|
|
|
|
* <p>Consider creating a special no-op marker class or interface in each package
|
|
|
|
* that serves no purpose other than being referenced by this attribute. |
|
|
|
* that serves no purpose other than being referenced by this attribute. |
|
|
|
@ -110,16 +110,16 @@ public @interface ControllerAdvice { |
|
|
|
/** |
|
|
|
/** |
|
|
|
* Array of classes. |
|
|
|
* Array of classes. |
|
|
|
* <p>Controllers that are assignable to at least one of the given types |
|
|
|
* <p>Controllers that are assignable to at least one of the given types |
|
|
|
* will be assisted by the {@code @ControllerAdvice} annotated class. |
|
|
|
* will be advised by the {@code @ControllerAdvice} annotated class. |
|
|
|
* @since 4.0 |
|
|
|
* @since 4.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
Class<?>[] assignableTypes() default {}; |
|
|
|
Class<?>[] assignableTypes() default {}; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Array of annotations. |
|
|
|
* Array of annotations. |
|
|
|
* <p>Controllers that are annotated with this/one of those annotation(s) |
|
|
|
* <p>Controllers that are annotated with at least one of the supplied annotations |
|
|
|
* will be assisted by the {@code @ControllerAdvice} annotated class. |
|
|
|
* will be advised by the {@code @ControllerAdvice} annotated class. |
|
|
|
* <p>Consider creating a special annotation or use a predefined one, |
|
|
|
* <p>Consider creating a custom composed annotation or use a predefined one, |
|
|
|
* like {@link RestController @RestController}. |
|
|
|
* like {@link RestController @RestController}. |
|
|
|
* @since 4.0 |
|
|
|
* @since 4.0 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
|