类 JsonViewResponseBodyAdvice
java.lang.Object
cn.taketoday.web.handler.method.AbstractMappingJacksonResponseBodyAdvice
cn.taketoday.web.handler.method.JsonViewResponseBodyAdvice
- 所有已实现的接口:
ResponseBodyAdvice<Object>
A
ResponseBodyAdvice implementation that adds support for Jackson's
@JsonView annotation declared on MVC @RequestMapping or
@ExceptionHandler method.
The serialization view specified in the annotation will be passed in to the
MappingJackson2HttpMessageConverter
which will then use it to serialize the response body.
Note that despite @JsonView allowing for more than one class to
be specified, the use for a response body advice is only supported with
exactly one class argument. Consider the use of a composite interface.
- 从以下版本开始:
- 4.0 2022/2/11 21:02
- 作者:
- Rossen Stoyanchev, Harry Yang
- 另请参阅:
-
JsonViewObjectMapper.writerWithView(Class)
-
构造器概要
构造器 -
方法概要
修饰符和类型方法说明protected voidbeforeBodyWriteInternal(MappingJacksonValue value, MediaType contentType, cn.taketoday.core.MethodParameter returnType, RequestContext request) Invoked only if the converter type isMappingJackson2HttpMessageConverter.booleansupports(Object body, cn.taketoday.core.MethodParameter returnType, HttpMessageConverter<?> converter) Whether this component supports the given controller method return type and the selectedHttpMessageConvertertype.从类继承的方法 cn.taketoday.web.handler.method.AbstractMappingJacksonResponseBodyAdvice
beforeBodyWrite, getOrCreateContainer
-
构造器详细资料
-
JsonViewResponseBodyAdvice
public JsonViewResponseBodyAdvice()
-
-
方法详细资料
-
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>- 覆盖:
supports在类中AbstractMappingJacksonResponseBodyAdvicereturnType- 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
-
beforeBodyWriteInternal
protected void beforeBodyWriteInternal(MappingJacksonValue value, MediaType contentType, cn.taketoday.core.MethodParameter returnType, RequestContext request) Invoked only if the converter type isMappingJackson2HttpMessageConverter.
-