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,
org.springframework.core.MethodParameter returnType,
org.springframework.http.MediaType contentType,
Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType,
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. |
protected abstract void |
beforeBodyWriteInternal(org.springframework.http.converter.json.MappingJacksonValue bodyContainer,
org.springframework.http.MediaType contentType,
org.springframework.core.MethodParameter returnType,
org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response)
Invoked only if the converter type is
MappingJackson2HttpMessageConverter. |
protected org.springframework.http.converter.json.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(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. |
public AbstractMappingJacksonResponseBodyAdvice()
public boolean supports(org.springframework.core.MethodParameter returnType,
Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType)
ResponseBodyAdviceHttpMessageConverter 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, org.springframework.core.MethodParameter returnType, org.springframework.http.MediaType contentType, Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType, org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response)
ResponseBodyAdviceHttpMessageConverter 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 org.springframework.http.converter.json.MappingJacksonValue getOrCreateContainer(Object body)
MappingJacksonValue value container (for providing
additional serialization instructions) or simply cast it if already wrapped.protected abstract void beforeBodyWriteInternal(org.springframework.http.converter.json.MappingJacksonValue bodyContainer,
org.springframework.http.MediaType contentType,
org.springframework.core.MethodParameter returnType,
org.springframework.http.server.ServerHttpRequest request,
org.springframework.http.server.ServerHttpResponse response)
MappingJackson2HttpMessageConverter.