Skip to content

Commit 2f4c97c

Browse files
committed
Merge branch '5.1.x'
2 parents 1d2f8e5 + 97bfb75 commit 2f4c97c

File tree

2 files changed

+41
-39
lines changed

2 files changed

+41
-39
lines changed

src/docs/asciidoc/web/webflux.adoc

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -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`]
26822683
javadoc for more details.
26832684

src/docs/asciidoc/web/webmvc.adoc

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -3120,23 +3120,24 @@ necessary methods, and declare it as a Spring bean.
31203120
Typically `@ExceptionHandler`, `@InitBinder`, and `@ModelAttribute` methods apply within
31213121
the `@Controller` class (or class hierarchy) in which they are declared. If you want such
31223122
methods to apply more globally (across controllers), you can declare them in a class
3123-
marked with `@ControllerAdvice` or `@RestControllerAdvice`.
3124-
3125-
`@ControllerAdvice` is marked with `@Component`, which means such classes can be registered
3126-
as Spring beans through <<core.adoc#beans-java-instantiating-container-scan, component scanning>>.
3127-
`@RestControllerAdvice` is also a meta-annotation marked with both `@ControllerAdvice` and
3128-
`@ResponseBody`, which essentially means `@ExceptionHandler` methods are rendered to the
3129-
response body through message conversion (versus view resolution or template rendering).
3130-
3131-
On startup, the infrastructure classes for `@RequestMapping` and `@ExceptionHandler` methods
3132-
detect Spring beans of type `@ControllerAdvice` and then apply their methods at runtime.
3133-
Global `@ExceptionHandler` methods (from a `@ControllerAdvice`) are applied _after_ local
3134-
ones (from the `@Controller`). By contrast, global `@ModelAttribute` and `@InitBinder`
3135-
methods are applied _before_ local ones.
3136-
3137-
By default, `@ControllerAdvice` methods apply to every request (that is, all controllers), but
3138-
you can narrow that down to a subset of controllers by using attributes on the annotation,
3139-
as the following example shows:
3123+
annotated with `@ControllerAdvice` or `@RestControllerAdvice`.
3124+
3125+
`@ControllerAdvice` is annotated with `@Component`, which means such classes can be
3126+
registered as Spring beans through <<core.adoc#beans-java-instantiating-container-scan,
3127+
component scanning>>. `@RestControllerAdvice` is a composed annotation that is annotated
3128+
with both `@ControllerAdvice` and `@ResponseBody`, which essentially means
3129+
`@ExceptionHandler` methods are rendered to the response body through message conversion
3130+
(versus view resolution or template rendering).
3131+
3132+
On startup, the infrastructure classes for `@RequestMapping` and `@ExceptionHandler`
3133+
methods detect Spring beans annotated with `@ControllerAdvice` and then apply their
3134+
methods at runtime. Global `@ExceptionHandler` methods (from a `@ControllerAdvice`) are
3135+
applied _after_ local ones (from the `@Controller`). By contrast, global `@ModelAttribute`
3136+
and `@InitBinder` methods are applied _before_ local ones.
3137+
3138+
By default, `@ControllerAdvice` methods apply to every request (that is, all controllers),
3139+
but you can narrow that down to a subset of controllers by using attributes on the
3140+
annotation, as the following example shows:
31403141

31413142
[source,java,indent=0]
31423143
[subs="verbatim,quotes"]

0 commit comments

Comments
 (0)