类 AbstractMappingJacksonResponseBodyAdvice
- java.lang.Object
- org.springframework.web.servlet.mvc.method.annotation.AbstractMappingJacksonResponseBodyAdvice
- 所有已实现的接口:
ResponseBodyAdvice<Object>
- 直接已知子类:
JsonViewResponseBodyAdvice
public abstract class AbstractMappingJacksonResponseBodyAdvice extends Object implements ResponseBodyAdvice<Object>
A convenient base class forResponseBodyAdvice
implementations that customize the response before JSON serialization withAbstractJackson2HttpMessageConverter
's concrete subclasses.- 从以下版本开始:
- 4.1
- 作者:
- Rossen Stoyanchev, Sebastien Deleuze
构造器概要
构造器 构造器 说明 AbstractMappingJacksonResponseBodyAdvice()
方法概要
所有方法 实例方法 抽象方法 具体方法 修饰符和类型 方法 说明 Object
beforeBodyWrite(Object body, MethodParameter returnType, MediaType contentType, Class<? extends HttpMessageConverter<?>> converterType, ServerHttpRequest request, ServerHttpResponse response)
Invoked after anHttpMessageConverter
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 isMappingJackson2HttpMessageConverter
.protected MappingJacksonValue
getOrCreateContainer(Object body)
Wrap the body in aMappingJacksonValue
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 selectedHttpMessageConverter
type.
构造器详细资料
AbstractMappingJacksonResponseBodyAdvice
public AbstractMappingJacksonResponseBodyAdvice()
方法详细资料
supports
public boolean supports(MethodParameter returnType, Class<? extends HttpMessageConverter<?>> converterType)
从接口复制的说明:ResponseBodyAdvice
Whether this component supports the given controller method return type and the selectedHttpMessageConverter
type.- 指定者:
supports
在接口中ResponseBodyAdvice<Object>
- 参数:
returnType
- the return typeconverterType
- the selected converter type- 返回:
true
ifResponseBodyAdvice.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
beforeBodyWrite
@Nullable public final Object beforeBodyWrite(@Nullable Object body, MethodParameter returnType, MediaType contentType, Class<? extends HttpMessageConverter<?>> converterType, ServerHttpRequest request, ServerHttpResponse response)
从接口复制的说明:ResponseBodyAdvice
Invoked after anHttpMessageConverter
is selected and just before its write method is invoked.- 指定者:
beforeBodyWrite
在接口中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 response- 返回:
- the body that was passed in or a modified (possibly new) instance
getOrCreateContainer
protected MappingJacksonValue getOrCreateContainer(Object body)
Wrap the body in aMappingJacksonValue
value container (for providing additional serialization instructions) or simply cast it if already wrapped.
beforeBodyWriteInternal
protected abstract void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, MethodParameter returnType, ServerHttpRequest request, ServerHttpResponse response)
Invoked only if the converter type isMappingJackson2HttpMessageConverter
.