@@ -10,18 +10,20 @@ to any controller. Moreover, as of 5.3, `@ExceptionHandler` methods in `@Control
1010can be used to handle exceptions from any `@Controller` or any other handler.
1111
1212`@ControllerAdvice` is meta-annotated with `@Component` and therefore can be registered as
13- a Spring bean through xref:core/beans/java/instantiating-container.adoc#beans-java-instantiating-container-scan[component scanning]
14- . `@RestControllerAdvice` is meta-annotated with `@ControllerAdvice`
15- and `@ResponseBody`, and that means `@ExceptionHandler` methods will have their return
16- value rendered via response body message conversion, rather than via HTML views.
13+ a Spring bean through xref:core/beans/java/instantiating-container.adoc#beans-java-instantiating-container-scan[component scanning].
14+
15+ `@RestControllerAdvice` is a shortcut annotation that combines `@ControllerAdvice`
16+ with `@ResponseBody`, in effect simply an `@ControllerAdvice` whose exception handler
17+ methods render to the response body.
1718
1819On startup, `RequestMappingHandlerMapping` and `ExceptionHandlerExceptionResolver` detect
1920controller advice beans and apply them at runtime. Global `@ExceptionHandler` methods,
2021from an `@ControllerAdvice`, are applied _after_ local ones, from the `@Controller`.
2122By contrast, global `@ModelAttribute` and `@InitBinder` methods are applied _before_ local ones.
2223
23- The `@ControllerAdvice` annotation has attributes that let you narrow the set of controllers
24- and handlers that they apply to. For example:
24+ By default, both `@ControllerAdvice` and `@RestControllerAdvice` apply to any controller,
25+ including `@Controller` and `@RestController`. Use attributes of the annotation to narrow
26+ the set of controllers and handlers that they apply to. For example:
2527
2628[tabs]
2729======
0 commit comments