类 JsonViewRequestBodyAdvice
- java.lang.Object
- org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdviceAdapter
- org.springframework.web.servlet.mvc.method.annotation.JsonViewRequestBodyAdvice
- 所有已实现的接口:
RequestBodyAdvice
public class JsonViewRequestBodyAdvice extends RequestBodyAdviceAdapter
ARequestBodyAdvice
implementation that adds support for Jackson's@JsonView
annotation declared on a Spring MVC@HttpEntity
or@RequestBody
method parameter.The deserialization view specified in the annotation will be passed in to the
MappingJackson2HttpMessageConverter
which will then use it to deserialize the request body with.Note that despite
@JsonView
allowing for more than one class to be specified, the use for a request body advice is only supported with exactly one class argument. Consider the use of a composite interface.Jackson 2.5 or later is required for parameter-level use of
@JsonView
.- 从以下版本开始:
- 4.2
- 作者:
- Sebastien Deleuze
- 另请参阅:
JsonView
,ObjectMapper.readerWithView(Class)
构造器概要
构造器 构造器 说明 JsonViewRequestBodyAdvice()
方法概要
所有方法 实例方法 具体方法 修饰符和类型 方法 说明 HttpInputMessage
beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> selectedConverterType)
The default implementation returns the InputMessage that was passed in.boolean
supports(MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
Invoked first to determine if this interceptor applies.从类继承的方法 org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdviceAdapter
afterBodyRead, handleEmptyBody
构造器详细资料
JsonViewRequestBodyAdvice
public JsonViewRequestBodyAdvice()
方法详细资料
supports
public boolean supports(MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType)
从接口复制的说明:RequestBodyAdvice
Invoked first to determine if this interceptor applies.- 参数:
methodParameter
- the method parametertargetType
- the target type, not necessarily the same as the method parameter type, e.g. forHttpEntity<String>
.converterType
- the selected converter type- 返回:
- whether this interceptor should be invoked or not
beforeBodyRead
public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter, Type targetType, Class<? extends HttpMessageConverter<?>> selectedConverterType) throws IOException
从类复制的说明:RequestBodyAdviceAdapter
The default implementation returns the InputMessage that was passed in.- 指定者:
beforeBodyRead
在接口中RequestBodyAdvice
- 覆盖:
beforeBodyRead
在类中RequestBodyAdviceAdapter
- 参数:
inputMessage
- the requestmethodParameter
- the target method parametertargetType
- the target type, not necessarily the same as the method parameter type, e.g. forHttpEntity<String>
.selectedConverterType
- the converter used to deserialize the body- 返回:
- the input request or a new instance, never
null
- 抛出:
IOException