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

RequestBodyAdvice

interface RequestBodyAdvice

Allows customizing the request before its body is read and converted into an Object and also allows for processing of the resulting Object before it is passed into a controller method as an @RequestBody or an HttpEntity method argument.

Implementations of this contract may be registered directly with the RequestMappingHandlerAdapter or more likely annotated with @ControllerAdvice in which case they are auto-detected.

Author
Rossen Stoyanchev

Since
4.2

Functions

afterBodyRead

abstract fun afterBodyRead(body: Any, inputMessage: HttpInputMessage, parameter: MethodParameter, targetType: Type, converterType: Class<out HttpMessageConverter<*>>): Any

Invoked third (and last) after the request body is converted to an Object.

beforeBodyRead

abstract fun beforeBodyRead(inputMessage: HttpInputMessage, parameter: MethodParameter, targetType: Type, converterType: Class<out HttpMessageConverter<*>>): HttpInputMessage

Invoked second before the request body is read and converted.

handleEmptyBody

abstract fun handleEmptyBody(body: Any, inputMessage: HttpInputMessage, parameter: MethodParameter, targetType: Type, converterType: Class<out HttpMessageConverter<*>>): Any

Invoked second (and last) if the body is empty.

supports

abstract fun supports(methodParameter: MethodParameter, targetType: Type, converterType: Class<out HttpMessageConverter<*>>): Boolean

Invoked first to determine if this interceptor applies.