@@ -2639,26 +2639,27 @@ an HTTP status code.
26392639=== Controller Advice
26402640[.small]#<<web.adoc#mvc-ann-controller-advice, Same as in Spring MVC>>#
26412641
2642- Typically, the `@ExceptionHandler`, `@InitBinder`, and `@ModelAttribute` methods apply within
2643- the `@Controller` class (or class hierarchy) in which they are declared. If you want such
2644- methods to apply more globally (across controllers), you can declare them in a class
2645- marked with `@ControllerAdvice` or `@RestControllerAdvice`.
2646-
2647- `@ControllerAdvice` is marked with `@Component`, which means that such classes can be registered
2648- as Spring beans through <<core.adoc#beans-java-instantiating-container-scan, component scanning>>.
2649- `@RestControllerAdvice` is also a meta-annotation marked with both `@ControllerAdvice` and
2650- `@ResponseBody`, which essentially means `@ExceptionHandler` methods are rendered to the
2651- response body through message conversion (versus view resolution or template rendering).
2652-
2653- On startup, the infrastructure classes for `@RequestMapping` and `@ExceptionHandler` methods
2654- detect Spring beans of type `@ControllerAdvice` and apply their methods at runtime.
2655- Global `@ExceptionHandler` methods (from a `@ControllerAdvice`) are applied *after* local
2656- ones (from the `@Controller`). By contrast, global `@ModelAttribute` and `@InitBinder`
2657- methods are applied *before* local ones.
2658-
2659- By default `@ControllerAdvice` methods apply to every request (that is, all controllers), but
2660- you can narrow that down to a subset of controllers through attributes on the annotation,
2661- as the following example shows:
2642+ Typically, the `@ExceptionHandler`, `@InitBinder`, and `@ModelAttribute` methods apply
2643+ within the `@Controller` class (or class hierarchy) in which they are declared. If you
2644+ want such methods to apply more globally (across controllers), you can declare them in a
2645+ class annotated with `@ControllerAdvice` or `@RestControllerAdvice`.
2646+
2647+ `@ControllerAdvice` is annotated with `@Component`, which means that such classes can be
2648+ registered as Spring beans through <<core.adoc#beans-java-instantiating-container-scan,
2649+ component scanning>>. `@RestControllerAdvice` is a composed annotation that is annotated
2650+ with both `@ControllerAdvice` and `@ResponseBody`, which essentially means
2651+ `@ExceptionHandler` methods are rendered to the response body through message conversion
2652+ (versus view resolution or template rendering).
2653+
2654+ On startup, the infrastructure classes for `@RequestMapping` and `@ExceptionHandler`
2655+ methods detect Spring beans annotated with `@ControllerAdvice` and then apply their
2656+ methods at runtime. Global `@ExceptionHandler` methods (from a `@ControllerAdvice`) are
2657+ applied _after_ local ones (from the `@Controller`). By contrast, global `@ModelAttribute`
2658+ and `@InitBinder` methods are applied _before_ local ones.
2659+
2660+ By default, `@ControllerAdvice` methods apply to every request (that is, all controllers),
2661+ but you can narrow that down to a subset of controllers by using attributes on the
2662+ annotation, as the following example shows:
26622663
26632664[source,java,indent=0]
26642665[subs="verbatim,quotes"]
@@ -2676,8 +2677,8 @@ as the following example shows:
26762677 public class ExampleAdvice3 {}
26772678----
26782679
2679- The preceding selectors are evaluated at runtime and may negatively impact
2680- performance if you use them extensively. See the
2680+ The selectors in the preceding example are evaluated at runtime and may negatively impact
2681+ performance if used extensively. See the
26812682{api-spring-framework}/web/bind/annotation/ControllerAdvice.html[`@ControllerAdvice`]
26822683javadoc for more details.
26832684
0 commit comments