Class 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
  • 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)
      Complete constructor for resolving HttpEntity and handling ResponseEntity.
  • 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 (e.g. ResponseEntity<T>).
      Overrides:
      getReturnValueType in class AbstractMessageConverterMethodProcessor