Package org.springframework.web.servlet.mvc.method.annotation

# Class HttpEntityMethodProcessor

java.lang.Object
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver
org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor
org.springframework.web.servlet.mvc.method.annotation.HttpEntityMethodProcessor

All Implemented Interfaces:
  `org.springframework.web.method.support.HandlerMethodArgumentResolver`, `org.springframework.web.method.support.HandlerMethodReturnValueHandler`

public class HttpEntityMethodProcessor extends AbstractMessageConverterMethodProcessor
Resolves `HttpEntity` and `RequestEntity` method argument values, as well as return values of type `HttpEntity`, `ResponseEntity`, `ErrorResponse` and `ProblemDetail`.

An `HttpEntity` return type has a specific purpose. Therefore, this handler should be configured ahead of handlers that support any return value type annotated with `@ModelAttribute` or `@ResponseBody` to ensure they don't take over.

Since:
  3.1
Author:
  Arjen Poutsma, Rossen Stoyanchev, Brian Clozel, Sam Brannen

## Nested Class Summary

## Nested classes/interfaces inherited from class org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver

`AbstractMessageConverterMethodArgumentResolver.ConverterType`

## Field Summary

### Fields inherited from class org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver

`logger, messageConverters`

## Constructor Summary

Constructors
Constructor
Description
`HttpEntityMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> converters)`
Basic constructor with converters only.
`HttpEntityMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> converters, List<Object> requestResponseBodyAdvice)`
Complete constructor for resolving `HttpEntity` method arguments.
`HttpEntityMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> converters, org.springframework.web.accept.ContentNegotiationManager manager)`
Basic constructor with converters and `ContentNegotiationManager`.
`HttpEntityMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> converters, org.springframework.web.accept.ContentNegotiationManager manager, List<Object> requestResponseBodyAdvice)`
Variant of `HttpEntityMethodProcessor(List, List)` with an additional `ContentNegotiationManager` argument for return value handling.
`HttpEntityMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> converters, org.springframework.web.accept.ContentNegotiationManager manager, List<Object> requestResponseBodyAdvice, List<org.springframework.web.ErrorResponse.Interceptor> interceptors)`
Variant of `HttpEntityMethodProcessor(List, ContentNegotiationManager, List)` with additional list of `ErrorResponse.Interceptor`s for return value handling.

## Method Summary

Modifier and Type
Method
Description
`protected Class<?>`
`getReturnValueType(Object returnValue, org.springframework.core.MethodParameter returnType)`
Return the type of the value to be written to the response.
`void`
`handleReturnValue(Object returnValue, org.springframework.core.MethodParameter returnType, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest)`
`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)`

### Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodProcessor

`createOutputMessage, getProducibleMediaTypes, getProducibleMediaTypes, invokeErrorResponseInterceptors, isResourceType, writeWithMessageConverters, writeWithMessageConverters`

### Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver

`adaptArgumentIfNecessary, createInputMessage, getNestedTypeIfNeeded, getSupportedMediaTypes, isBindExceptionRequired, readWithMessageConverters, readWithMessageConverters, validateIfApplicable`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### HttpEntityMethodProcessor

public HttpEntityMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> converters)
Basic constructor with converters only. Suitable for resolving `HttpEntity`. For handling `ResponseEntity` consider also providing a `ContentNegotiationManager`.

### HttpEntityMethodProcessor

public HttpEntityMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> converters, org.springframework.web.accept.ContentNegotiationManager manager)
Basic constructor with converters and `ContentNegotiationManager`. Suitable for resolving `HttpEntity` and handling `ResponseEntity` without `Request~` or `ResponseBodyAdvice`.

### HttpEntityMethodProcessor

public HttpEntityMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> converters, List<Object> requestResponseBodyAdvice)
Complete constructor for resolving `HttpEntity` method arguments. For handling `ResponseEntity` consider also providing a `ContentNegotiationManager`.

Since:
  4.2

### HttpEntityMethodProcessor

public HttpEntityMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> converters, @Nullable org.springframework.web.accept.ContentNegotiationManager manager, List<Object> requestResponseBodyAdvice)
Variant of `HttpEntityMethodProcessor(List, List)` with an additional `ContentNegotiationManager` argument for return value handling.

### HttpEntityMethodProcessor

public HttpEntityMethodProcessor(List<org.springframework.http.converter.HttpMessageConverter<?>> converters, @Nullable org.springframework.web.accept.ContentNegotiationManager manager, List<Object> requestResponseBodyAdvice, List<org.springframework.web.ErrorResponse.Interceptor> interceptors)
Variant of `HttpEntityMethodProcessor(List, ContentNegotiationManager, List)` with additional list of `ErrorResponse.Interceptor`s for return value handling.

Since:
  6.2

## Method Details

### supportsParameter

public boolean supportsParameter(org.springframework.core.MethodParameter parameter)

### supportsReturnType

public boolean supportsReturnType(org.springframework.core.MethodParameter returnType)

### resolveArgument

@Nullable public 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 IOException, org.springframework.web.HttpMediaTypeNotSupportedException

Throws:
  `IOException`
  `org.springframework.web.HttpMediaTypeNotSupportedException`

### handleReturnValue

public void handleReturnValue(@Nullable Object returnValue, org.springframework.core.MethodParameter returnType, org.springframework.web.method.support.ModelAndViewContainer mavContainer, org.springframework.web.context.request.NativeWebRequest webRequest) throws Exception

Throws:
  `Exception`

### getReturnValueType

protected Class<?> getReturnValueType(@Nullable Object returnValue, org.springframework.core.MethodParameter returnType)
Description copied from class: `AbstractMessageConverterMethodProcessor`
Return the type of the value to be written to the response. Typically this is a simple check via getClass on the value but if the value is null, then the return type needs to be examined possibly including generic type determination (for example, `ResponseEntity<T>`).

Overrides:
  `getReturnValueType` in class `AbstractMessageConverterMethodProcessor`