public class JsonViewRequestBodyAdvice extends RequestBodyAdviceAdapter
RequestBodyAdvice 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.
JsonView,
ObjectMapper.readerWithView(Class)| Constructor and Description |
|---|
JsonViewRequestBodyAdvice() |
| Modifier and Type | Method and Description |
|---|---|
HttpInputMessage |
beforeBodyRead(HttpInputMessage inputMessage,
MethodParameter methodParameter,
java.lang.reflect.Type targetType,
java.lang.Class<? extends HttpMessageConverter<?>> selectedConverterType)
The default implementation returns the InputMessage that was passed in.
|
boolean |
supports(MethodParameter methodParameter,
java.lang.reflect.Type targetType,
java.lang.Class<? extends HttpMessageConverter<?>> converterType)
Invoked first to determine if this interceptor applies.
|
afterBodyRead, handleEmptyBodypublic boolean supports(MethodParameter methodParameter, java.lang.reflect.Type targetType, java.lang.Class<? extends HttpMessageConverter<?>> converterType)
RequestBodyAdvicemethodParameter - the method parametertargetType - the target type, not necessarily the same as the method
parameter type, e.g. for HttpEntity<String>.converterType - the selected converter typepublic HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter methodParameter, java.lang.reflect.Type targetType, java.lang.Class<? extends HttpMessageConverter<?>> selectedConverterType) throws java.io.IOException
RequestBodyAdviceAdapterbeforeBodyRead in interface RequestBodyAdvicebeforeBodyRead in class RequestBodyAdviceAdapterinputMessage - the requestmethodParameter - the target method parametertargetType - the target type, not necessarily the same as the method
parameter type, e.g. for HttpEntity<String>.selectedConverterType - the converter used to deserialize the bodynulljava.io.IOException