public class RequestResponseBodyMethodProcessor extends AbstractMessageConverterMethodProcessor
@RequestBody and handles return
values from methods annotated with @ResponseBody by reading and writing
to the body of the request or response with an HttpMessageConverter.
An @RequestBody method argument is also validated if it is annotated
with any
annotations that trigger validation. In case of validation failure,
MethodArgumentNotValidException is raised and results in an HTTP 400
response status code if DefaultHandlerExceptionResolver is configured.
logger, messageConverters| Constructor and Description |
|---|
RequestResponseBodyMethodProcessor(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters)
Basic constructor with converters only.
|
RequestResponseBodyMethodProcessor(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters,
org.springframework.web.accept.ContentNegotiationManager manager)
Basic constructor with converters and
ContentNegotiationManager. |
RequestResponseBodyMethodProcessor(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters,
org.springframework.web.accept.ContentNegotiationManager manager,
java.util.List<java.lang.Object> requestResponseBodyAdvice)
Complete constructor for resolving
@RequestBody and handling
@ResponseBody. |
RequestResponseBodyMethodProcessor(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters,
java.util.List<java.lang.Object> requestResponseBodyAdvice)
Complete constructor for resolving
@RequestBody method arguments. |
| Modifier and Type | Method and Description |
|---|---|
protected boolean |
checkRequired(org.springframework.core.MethodParameter parameter) |
void |
handleReturnValue(java.lang.Object returnValue,
org.springframework.core.MethodParameter returnType,
org.springframework.web.method.support.ModelAndViewContainer mavContainer,
org.springframework.web.context.request.NativeWebRequest webRequest) |
protected <T> java.lang.Object |
readWithMessageConverters(org.springframework.web.context.request.NativeWebRequest webRequest,
org.springframework.core.MethodParameter parameter,
java.lang.reflect.Type paramType)
Create the method argument value of the expected parameter type by
reading from the given request.
|
java.lang.Object |
resolveArgument(org.springframework.core.MethodParameter parameter,
org.springframework.web.method.support.ModelAndViewContainer mavContainer,
org.springframework.web.context.request.NativeWebRequest webRequest,
org.springframework.web.bind.support.WebDataBinderFactory binderFactory)
Throws MethodArgumentNotValidException if validation fails.
|
boolean |
supportsParameter(org.springframework.core.MethodParameter parameter) |
boolean |
supportsReturnType(org.springframework.core.MethodParameter returnType) |
createOutputMessage, getProducibleMediaTypes, getProducibleMediaTypes, getReturnValueType, isResourceType, writeWithMessageConverters, writeWithMessageConvertersadaptArgumentIfNecessary, createInputMessage, getSupportedMediaTypes, isBindExceptionRequired, readWithMessageConverters, validateIfApplicablepublic RequestResponseBodyMethodProcessor(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters)
@RequestBody. For handling @ResponseBody consider also
providing a ContentNegotiationManager.public RequestResponseBodyMethodProcessor(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters,
@Nullable
org.springframework.web.accept.ContentNegotiationManager manager)
ContentNegotiationManager.
Suitable for resolving @RequestBody and handling
@ResponseBody without Request~ or
ResponseBodyAdvice.public RequestResponseBodyMethodProcessor(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters,
@Nullable
java.util.List<java.lang.Object> requestResponseBodyAdvice)
@RequestBody method arguments.
For handling @ResponseBody consider also providing a
ContentNegotiationManager.public RequestResponseBodyMethodProcessor(java.util.List<org.springframework.http.converter.HttpMessageConverter<?>> converters,
@Nullable
org.springframework.web.accept.ContentNegotiationManager manager,
@Nullable
java.util.List<java.lang.Object> requestResponseBodyAdvice)
@RequestBody and handling
@ResponseBody.public boolean supportsParameter(org.springframework.core.MethodParameter parameter)
public boolean supportsReturnType(org.springframework.core.MethodParameter returnType)
public java.lang.Object resolveArgument(org.springframework.core.MethodParameter parameter,
@Nullable
org.springframework.web.method.support.ModelAndViewContainer mavContainer,
org.springframework.web.context.request.NativeWebRequest webRequest,
@Nullable
org.springframework.web.bind.support.WebDataBinderFactory binderFactory)
throws java.lang.Exception
org.springframework.http.converter.HttpMessageNotReadableException - if RequestBody.required()
is true and there is no body content or if there is no suitable
converter to read the content with.java.lang.Exceptionprotected <T> java.lang.Object readWithMessageConverters(org.springframework.web.context.request.NativeWebRequest webRequest,
org.springframework.core.MethodParameter parameter,
java.lang.reflect.Type paramType)
throws java.io.IOException,
org.springframework.web.HttpMediaTypeNotSupportedException,
org.springframework.http.converter.HttpMessageNotReadableException
AbstractMessageConverterMethodArgumentResolverreadWithMessageConverters in class AbstractMessageConverterMethodArgumentResolverT - the expected type of the argument value to be createdwebRequest - the current requestparameter - the method parameter descriptor (may be null)paramType - the type of the argument value to be createdjava.io.IOException - if the reading from the request failsorg.springframework.web.HttpMediaTypeNotSupportedException - if no suitable message converter is foundorg.springframework.http.converter.HttpMessageNotReadableExceptionprotected boolean checkRequired(org.springframework.core.MethodParameter parameter)
public void handleReturnValue(@Nullable
java.lang.Object returnValue,
org.springframework.core.MethodParameter returnType,
org.springframework.web.method.support.ModelAndViewContainer mavContainer,
org.springframework.web.context.request.NativeWebRequest webRequest)
throws java.io.IOException,
org.springframework.web.HttpMediaTypeNotAcceptableException,
org.springframework.http.converter.HttpMessageNotWritableException
java.io.IOExceptionorg.springframework.web.HttpMediaTypeNotAcceptableExceptionorg.springframework.http.converter.HttpMessageNotWritableException