spring-framework / org.springframework.web.servlet.mvc.method.annotation / RequestResponseBodyMethodProcessor

RequestResponseBodyMethodProcessor

open class RequestResponseBodyMethodProcessor : AbstractMessageConverterMethodProcessor

Resolves method arguments annotated with @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 an HTTP 400 response status code if DefaultHandlerExceptionResolver is configured.

Author
Arjen Poutsma

Author
Rossen Stoyanchev

Author
Juergen Hoeller

Since
3.1

Constructors

<init>

RequestResponseBodyMethodProcessor(converters: MutableList<HttpMessageConverter<*>>)

Basic constructor with converters only. Suitable for resolving @RequestBody. For handling @ResponseBody consider also providing a ContentNegotiationManager.

RequestResponseBodyMethodProcessor(converters: MutableList<HttpMessageConverter<*>>, manager: ContentNegotiationManager)

Basic constructor with converters and ContentNegotiationManager. Suitable for resolving @RequestBody and handling @ResponseBody without Request~ or ResponseBodyAdvice.

RequestResponseBodyMethodProcessor(converters: MutableList<HttpMessageConverter<*>>, requestResponseBodyAdvice: MutableList<Any>)

Complete constructor for resolving @RequestBody method arguments. For handling @ResponseBody consider also providing a ContentNegotiationManager.

RequestResponseBodyMethodProcessor(converters: MutableList<HttpMessageConverter<*>>, manager: ContentNegotiationManager, requestResponseBodyAdvice: MutableList<Any>)

Complete constructor for resolving @RequestBody and handling @ResponseBody.

Functions

handleReturnValue

open fun handleReturnValue(returnValue: Any, returnType: MethodParameter, mavContainer: ModelAndViewContainer, webRequest: NativeWebRequest): Unit

resolveArgument

open fun resolveArgument(parameter: MethodParameter, mavContainer: ModelAndViewContainer, webRequest: NativeWebRequest, binderFactory: WebDataBinderFactory): Any

Throws MethodArgumentNotValidException if validation fails.

supportsParameter

open fun supportsParameter(parameter: MethodParameter): Boolean

supportsReturnType

open fun supportsReturnType(returnType: MethodParameter): Boolean