T - the body typepublic interface ResponseBodyAdvice<T>
@ResponseBody
or a ResponseEntity controller method but before the body is written
with an HttpMessageConverter.
Implementations may be registered directly with
RequestMappingHandlerAdapter and ExceptionHandlerExceptionResolver
or more likely annotated with @ControllerAdvice in which case they
will be auto-detected by both.
| Modifier and Type | Method and Description |
|---|---|
T |
beforeBodyWrite(T body,
org.springframework.core.MethodParameter returnType,
org.springframework.http.MediaType selectedContentType,
Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> selectedConverterType,
org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response)
Invoked after an
HttpMessageConverter is selected and just before
its write method is invoked. |
boolean |
supports(org.springframework.core.MethodParameter returnType,
Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType)
Whether this component supports the given controller method return type
and the selected
HttpMessageConverter type. |
boolean supports(org.springframework.core.MethodParameter returnType,
Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType)
HttpMessageConverter type.returnType - the return typeconverterType - the selected converter typetrue if beforeBodyWrite(T, org.springframework.core.MethodParameter, org.springframework.http.MediaType, java.lang.Class<? extends org.springframework.http.converter.HttpMessageConverter<?>>, org.springframework.http.server.ServerHttpRequest, org.springframework.http.server.ServerHttpResponse) should be invoked;
false otherwise@Nullable T beforeBodyWrite(@Nullable T body, org.springframework.core.MethodParameter returnType, org.springframework.http.MediaType selectedContentType, Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> selectedConverterType, org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response)
HttpMessageConverter is selected and just before
its write method is invoked.body - the body to be writtenreturnType - the return type of the controller methodselectedContentType - the content type selected through content negotiationselectedConverterType - the converter type selected to write to the responserequest - the current requestresponse - the current response