public abstract class AbstractMappingJacksonResponseBodyAdvice extends Object implements ResponseBodyAdvice<Object>
ResponseBodyAdvice
implementations
that customize the response before JSON serialization with
AbstractJackson2HttpMessageConverter
's concrete subclasses.Constructor and Description |
---|
AbstractMappingJacksonResponseBodyAdvice() |
Modifier and Type | Method and Description |
---|---|
Object |
beforeBodyWrite(Object body,
MethodParameter returnType,
MediaType contentType,
Class<? extends HttpMessageConverter<?>> converterType,
ServerHttpRequest request,
ServerHttpResponse response)
Invoked after an
HttpMessageConverter is selected and just before
its write method is invoked. |
protected abstract void |
beforeBodyWriteInternal(MappingJacksonValue bodyContainer,
MediaType contentType,
MethodParameter returnType,
ServerHttpRequest request,
ServerHttpResponse response)
Invoked only if the converter type is
MappingJackson2HttpMessageConverter . |
protected MappingJacksonValue |
getOrCreateContainer(Object body)
Wrap the body in a
MappingJacksonValue value container (for providing
additional serialization instructions) or simply cast it if already wrapped. |
boolean |
supports(MethodParameter returnType,
Class<? extends HttpMessageConverter<?>> converterType)
Whether this component supports the given controller method return type
and the selected
HttpMessageConverter type. |
public AbstractMappingJacksonResponseBodyAdvice()
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType)
ResponseBodyAdvice
HttpMessageConverter
type.supports
in interface ResponseBodyAdvice<Object>
returnType
- the return typeconverterType
- the selected converter typetrue
if ResponseBodyAdvice.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 public final Object beforeBodyWrite(@Nullable Object body, MethodParameter returnType, MediaType contentType, Class<? extends HttpMessageConverter<?>> converterType, ServerHttpRequest request, ServerHttpResponse response)
ResponseBodyAdvice
HttpMessageConverter
is selected and just before
its write method is invoked.beforeBodyWrite
in interface ResponseBodyAdvice<Object>
body
- the body to be writtenreturnType
- the return type of the controller methodcontentType
- the content type selected through content negotiationconverterType
- the converter type selected to write to the responserequest
- the current requestresponse
- the current responseprotected MappingJacksonValue getOrCreateContainer(Object body)
MappingJacksonValue
value container (for providing
additional serialization instructions) or simply cast it if already wrapped.protected abstract void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response)
MappingJackson2HttpMessageConverter
.