@ControllerAdvice
and @ResponseBody.
Types that carry this annotation are treated as controller advice where
@ExceptionHandler methods assume
@ResponseBody semantics by default.
Note
@RestControllerAdvice is processed if an appropriate
HandlerMapping-HandlerAdapter pair is configured such as the
RequestMappingHandlerMapping-RequestMappingHandlerAdapter pair
which are the default in the MVC Java config and the MVC namespace.
RestController, ControllerAdvice
| Modifier and Type | Method and Description |
|---|---|
| public Class | |
| public Class | |
| public Class | basePackageClasses()
Type-safe alternative to |
| public String[] | |
| public String | |
| public String[] |
| annotations | back to summary |
|---|---|
| public Class Array of annotations. Controllers that are annotated with at least one of the supplied annotation
types will be advised by the Consider creating a custom composed annotation or use a predefined one,
like
| |
| assignableTypes | back to summary |
|---|---|
| public Class Array of classes. Controllers that are assignable to at least one of the given types
will be advised by the
| |
| basePackageClasses | back to summary |
|---|---|
| public Class Type-safe alternative to Consider creating a special no-op marker class or interface in each package that serves no purpose other than being referenced by this attribute.
| |
| basePackages | back to summary |
|---|---|
| public String[] basePackages() Array of base packages. Controllers that belong to those base packages or sub-packages thereof
will be included — for example,
Also consider using
| |
| name | back to summary |
|---|---|
| public String name() Alias for
| |
| value | back to summary |
|---|---|
| public String[] value() Alias for the Allows for more concise annotation declarations — for example,
| |