类 AbstractMappingJacksonResponseBodyAdvice
java.lang.Object
cn.taketoday.web.handler.method.AbstractMappingJacksonResponseBodyAdvice
- 所有已实现的接口:
ResponseBodyAdvice<Object>
- 直接已知子类:
JsonViewResponseBodyAdvice
public abstract class AbstractMappingJacksonResponseBodyAdvice
extends Object
implements ResponseBodyAdvice<Object>
A convenient base class for
ResponseBodyAdvice implementations
that customize the response before JSON serialization with
AbstractJackson2HttpMessageConverter's concrete subclasses.- 从以下版本开始:
- 4.0 2022/2/11 20:59
- 作者:
- Rossen Stoyanchev, Sebastien Deleuze, Harry Yang
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明beforeBodyWrite(Object body, cn.taketoday.core.MethodParameter returnType, MediaType contentType, HttpMessageConverter<?> converter, RequestContext context) Invoked after anHttpMessageConverteris selected and just before its write method is invoked.protected abstract voidbeforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, cn.taketoday.core.MethodParameter returnType, RequestContext request) Invoked only if the converter type isMappingJackson2HttpMessageConverter.protected MappingJacksonValuegetOrCreateContainer(Object body) Wrap the body in aMappingJacksonValuevalue container (for providing additional serialization instructions) or simply cast it if already wrapped.booleansupports(Object body, cn.taketoday.core.MethodParameter returnType, HttpMessageConverter<?> converter) Whether this component supports the given controller method return type and the selectedHttpMessageConvertertype.
-
构造器详细资料
-
AbstractMappingJacksonResponseBodyAdvice
public AbstractMappingJacksonResponseBodyAdvice()
-
-
方法详细资料
-
supports
public boolean supports(@Nullable Object body, @Nullable cn.taketoday.core.MethodParameter returnType, HttpMessageConverter<?> converter) 从接口复制的说明:ResponseBodyAdviceWhether this component supports the given controller method return type and the selectedHttpMessageConvertertype.- 指定者:
supports在接口中ResponseBodyAdvice<Object>returnType- the return typeconverter- the selected converter- 返回:
trueifResponseBodyAdvice.beforeBodyWrite(java.lang.Object, cn.taketoday.core.MethodParameter, cn.taketoday.http.MediaType, cn.taketoday.http.converter.HttpMessageConverter<?>, cn.taketoday.web.RequestContext)should be invoked;falseotherwise
-
beforeBodyWrite
@Nullable public Object beforeBodyWrite(@Nullable Object body, @Nullable cn.taketoday.core.MethodParameter returnType, MediaType contentType, HttpMessageConverter<?> converter, RequestContext context) 从接口复制的说明:ResponseBodyAdviceInvoked after anHttpMessageConverteris 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 negotiationconverter- the converter selected to write to the responsecontext- the current request context- 返回:
- the body that was passed in or a modified (possibly new) instance
-
getOrCreateContainer
Wrap the body in aMappingJacksonValuevalue container (for providing additional serialization instructions) or simply cast it if already wrapped. -
beforeBodyWriteInternal
protected abstract void beforeBodyWriteInternal(MappingJacksonValue bodyContainer, MediaType contentType, @Nullable cn.taketoday.core.MethodParameter returnType, RequestContext request) Invoked only if the converter type isMappingJackson2HttpMessageConverter.
-