Skip to content

Commit 51a550b

Browse files
committed
Add mention of ResponseBodyAdvice
1 parent 3a8f306 commit 51a550b

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/asciidoc/index.adoc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1068,6 +1068,7 @@ method has been added.
10681068
methods just after the controller method returns and before the response is written.
10691069
To take advantage declare an `@ControllerAdvice` bean that implements `ResponseBodyAdvice`.
10701070
The built-in support for `@JsonView` and JSONP take advantage of this.
1071+
See <<mvc-handlermapping-interceptor>>.
10711072
* There are three new `HttpMessageConverter` options:
10721073
** Gson -- lighter footprint than Jackson; has already been in use in Spring Android.
10731074
** Google Protocol Buffers -- efficient and effective as an inter-service communication
@@ -32094,6 +32095,17 @@ interceptor applies, you can use the MVC namespace or the MVC Java config, or de
3209432095
bean instances of type `MappedInterceptor` to do that. See <<mvc-config-enable>>.
3209532096
====
3209632097

32098+
Note that the `postHandle` method of `HandlerInterceptor` is not always ideally suited for
32099+
use with `@ResponseBody` and `ResponseEntity` methods. In such cases an `HttpMessageConverter`
32100+
writes to and commits the response before `postHandle` is called which makes it impossible
32101+
to change the response, for example to add a header. Instead an application can implement
32102+
`ResponseBodyAdvice` and either declare it as an `@ControllerAdvice` bean or configure it
32103+
directly on `RequestMappingHandlerAdapter`.
32104+
32105+
32106+
32107+
32108+
3209732109

3209832110

3209932111

0 commit comments

Comments
 (0)