From 51a550b27b643424c06af26fa66d6b4c40607499 Mon Sep 17 00:00:00 2001 From: Rossen Stoyanchev Date: Wed, 3 Sep 2014 00:02:10 -0400 Subject: [PATCH] Add mention of ResponseBodyAdvice --- src/asciidoc/index.adoc | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/asciidoc/index.adoc b/src/asciidoc/index.adoc index e662fab748..086cb17545 100644 --- a/src/asciidoc/index.adoc +++ b/src/asciidoc/index.adoc @@ -1068,6 +1068,7 @@ method has been added. methods just after the controller method returns and before the response is written. To take advantage declare an `@ControllerAdvice` bean that implements `ResponseBodyAdvice`. The built-in support for `@JsonView` and JSONP take advantage of this. + See <>. * There are three new `HttpMessageConverter` options: ** Gson -- lighter footprint than Jackson; has already been in use in Spring Android. ** 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 bean instances of type `MappedInterceptor` to do that. See <>. ==== +Note that the `postHandle` method of `HandlerInterceptor` is not always ideally suited for +use with `@ResponseBody` and `ResponseEntity` methods. In such cases an `HttpMessageConverter` +writes to and commits the response before `postHandle` is called which makes it impossible +to change the response, for example to add a header. Instead an application can implement +`ResponseBodyAdvice` and either declare it as an `@ControllerAdvice` bean or configure it +directly on `RequestMappingHandlerAdapter`. + + + + +