public abstract class AbstractMappingJacksonResponseBodyAdvice extends java.lang.Object implements ResponseBodyAdvice<java.lang.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 |
---|---|
java.lang.Object |
beforeBodyWrite(java.lang.Object body,
org.springframework.core.MethodParameter returnType,
org.springframework.http.MediaType contentType,
java.lang.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(java.lang.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,
java.lang.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, java.lang.Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType)
ResponseBodyAdvice
HttpMessageConverter
type.supports
in interface ResponseBodyAdvice<java.lang.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 java.lang.Object beforeBodyWrite(@Nullable java.lang.Object body, org.springframework.core.MethodParameter returnType, org.springframework.http.MediaType contentType, java.lang.Class<? extends org.springframework.http.converter.HttpMessageConverter<?>> converterType, org.springframework.http.server.ServerHttpRequest request, org.springframework.http.server.ServerHttpResponse response)
ResponseBodyAdvice
HttpMessageConverter
is selected and just before
its write method is invoked.beforeBodyWrite
in interface ResponseBodyAdvice<java.lang.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(java.lang.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
.