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 @javax.validation.Valid. In case of validation
failure, MethodArgumentNotValidException is raised and results
in a 400 response status code if DefaultHandlerExceptionResolver
is configured.
allSupportedMediaTypes, logger, messageConverters| Constructor and Description |
|---|
RequestResponseBodyMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> messageConverters) |
RequestResponseBodyMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> messageConverters,
org.springframework.web.accept.ContentNegotiationManager contentNegotiationManager) |
| Modifier and Type | Method and Description |
|---|---|
void |
handleReturnValue(Object returnValue,
org.springframework.core.MethodParameter returnType,
org.springframework.web.method.support.ModelAndViewContainer mavContainer,
org.springframework.web.context.request.NativeWebRequest webRequest) |
protected <T> Object |
readWithMessageConverters(org.springframework.web.context.request.NativeWebRequest webRequest,
org.springframework.core.MethodParameter methodParam,
Type paramType)
Create the method argument value of the expected parameter type by
reading from the given request.
|
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) |
boolean |
supportsParameter(org.springframework.core.MethodParameter parameter) |
boolean |
supportsReturnType(org.springframework.core.MethodParameter returnType) |
createOutputMessage, getProducibleMediaTypes, writeWithMessageConverters, writeWithMessageConverterscreateInputMessage, readWithMessageConverterspublic RequestResponseBodyMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> messageConverters)
public RequestResponseBodyMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> messageConverters, org.springframework.web.accept.ContentNegotiationManager contentNegotiationManager)
public boolean supportsParameter(org.springframework.core.MethodParameter parameter)
public boolean supportsReturnType(org.springframework.core.MethodParameter returnType)
public 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 Exception
org.springframework.web.bind.MethodArgumentNotValidException - if validation failsorg.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.Exceptionprotected <T> Object readWithMessageConverters(org.springframework.web.context.request.NativeWebRequest webRequest, org.springframework.core.MethodParameter methodParam, Type paramType) throws IOException, org.springframework.web.HttpMediaTypeNotSupportedException
AbstractMessageConverterMethodArgumentResolverreadWithMessageConverters in class AbstractMessageConverterMethodArgumentResolverT - the expected type of the argument value to be createdwebRequest - the current requestmethodParam - the method argumentparamType - the type of the argument value to be createdIOException - if the reading from the request failsorg.springframework.web.HttpMediaTypeNotSupportedException - if no suitable message converter is foundpublic void handleReturnValue(Object returnValue, org.springframework.core.MethodParameter returnType, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest) throws IOException, org.springframework.web.HttpMediaTypeNotAcceptableException
IOExceptionorg.springframework.web.HttpMediaTypeNotAcceptableException