Class RequestBodyAdviceAdapter
java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdviceAdapter
- All Implemented Interfaces:
- RequestBodyAdvice
- Direct Known Subclasses:
- JsonViewRequestBodyAdvice
A convenient starting point for implementing
 
RequestBodyAdvice with default method implementations.
 Subclasses are required to implement RequestBodyAdvice.supports(org.springframework.core.MethodParameter, java.lang.reflect.Type, java.lang.Class<? extends org.springframework.http.converter.HttpMessageConverter<?>>) to return true
 depending on when the advice applies.
- Since:
- 4.2
- Author:
- Rossen Stoyanchev
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionafterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) The default implementation returns the body that was passed in.beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) The default implementation returns the InputMessage that was passed in.handleEmptyBody(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) The default implementation returns the body that was passed in.Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdvicesupports
- 
Constructor Details- 
RequestBodyAdviceAdapterpublic RequestBodyAdviceAdapter()
 
- 
- 
Method Details- 
beforeBodyReadpublic HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) throws IOException The default implementation returns the InputMessage that was passed in.- Specified by:
- beforeBodyReadin interface- RequestBodyAdvice
- Parameters:
- inputMessage- the request
- parameter- the target method parameter
- targetType- the target type, not necessarily the same as the method parameter type, e.g. for- HttpEntity<String>.
- converterType- the converter used to deserialize the body
- Returns:
- the input request or a new instance (never null)
- Throws:
- IOException
 
- 
afterBodyReadpublic Object afterBodyRead(Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) The default implementation returns the body that was passed in.- Specified by:
- afterBodyReadin interface- RequestBodyAdvice
- Parameters:
- body- set to the converter Object before the first advice is called
- inputMessage- the request
- parameter- the target method parameter
- targetType- the target type, not necessarily the same as the method parameter type, e.g. for- HttpEntity<String>.
- converterType- the converter used to deserialize the body
- Returns:
- the same body or a new instance
 
- 
handleEmptyBody@Nullable public Object handleEmptyBody(@Nullable Object body, HttpInputMessage inputMessage, MethodParameter parameter, Type targetType, Class<? extends HttpMessageConverter<?>> converterType) The default implementation returns the body that was passed in.- Specified by:
- handleEmptyBodyin interface- RequestBodyAdvice
- Parameters:
- body- usually set to- nullbefore the first advice is called
- inputMessage- the request
- parameter- the method parameter
- targetType- the target type, not necessarily the same as the method parameter type, e.g. for- HttpEntity<String>.
- converterType- the selected converter type
- Returns:
- the value to use, or nullwhich may then raise anHttpMessageNotReadableExceptionif the argument is required
 
 
-