类 AbstractMessageConverterMethodArgumentResolver

java.lang.Object
cn.taketoday.web.bind.resolver.AbstractMessageConverterMethodArgumentResolver
所有已实现的接口:
ParameterResolvingStrategy
直接已知子类:
AbstractMessageConverterMethodProcessor, RequestPartMethodArgumentResolver

public abstract class AbstractMessageConverterMethodArgumentResolver extends Object implements ParameterResolvingStrategy
A base class for resolving method argument values by reading from the body of a request with HttpMessageConverters.
从以下版本开始:
4.0 2022/1/22 19:40
作者:
Arjen Poutsma, Rossen Stoyanchev, Juergen Hoeller, Harry Yang
  • 字段详细资料

  • 构造器详细资料

    • AbstractMessageConverterMethodArgumentResolver

      public AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> converters)
      Basic constructor with converters only.
    • AbstractMessageConverterMethodArgumentResolver

      public AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> converters, @Nullable List<Object> requestResponseBodyAdvice)
      Constructor with converters and Request~ and ResponseBodyAdvice.
  • 方法详细资料

    • getAdvice

      Return the configured RequestBodyAdvice and RequestBodyAdvice where each instance may be wrapped as a ControllerAdviceBean.
    • readWithMessageConverters

      @Nullable protected Object readWithMessageConverters(RequestContext request, cn.taketoday.core.MethodParameter parameter, Type paramType) throws IOException, HttpMediaTypeNotSupportedException, HttpMessageNotReadableException
      Create the method argument value of the expected parameter type by reading from the given request.
      参数:
      request - the current request
      parameter - the method parameter descriptor (may be null)
      paramType - the type of the argument value to be created
      返回:
      the created method argument value
      抛出:
      IOException - if the reading from the request fails
      HttpMediaTypeNotSupportedException - if no suitable message converter is found
      HttpMessageNotReadableException
    • readWithMessageConverters

      @Nullable protected <T> Object readWithMessageConverters(HttpInputMessage inputMessage, cn.taketoday.core.MethodParameter parameter, Type targetType) throws IOException, HttpMediaTypeNotSupportedException, HttpMessageNotReadableException
      Create the method argument value of the expected parameter type by reading from the given HttpInputMessage.
      参数:
      inputMessage - the HTTP input message representing the current request
      parameter - the method parameter descriptor
      targetType - the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.
      返回:
      the created method argument value
      抛出:
      IOException - if the reading from the request fails
      HttpMediaTypeNotSupportedException - if no suitable message converter is found
      HttpMessageNotReadableException
    • validateIfApplicable

      protected void validateIfApplicable(RequestContext context, cn.taketoday.core.MethodParameter parameter, Object arg) throws Throwable
      抛出:
      Throwable
    • validateIfApplicable

      protected void validateIfApplicable(WebDataBinder binder, cn.taketoday.core.MethodParameter parameter)
      Validate the binding target if applicable.

      The default implementation checks for @jakarta.validation.Valid, Infra Validated, and custom annotations whose name starts with "Valid".

      参数:
      binder - the DataBinder to be used
      parameter - the method parameter descriptor
      另请参阅:
    • isBindExceptionRequired

      protected boolean isBindExceptionRequired(WebDataBinder binder, cn.taketoday.core.MethodParameter parameter)
      Whether to raise a fatal bind exception on validation errors.
      参数:
      binder - the data binder used to perform data binding
      parameter - the method parameter descriptor
      返回:
      true if the next method argument is not of type Errors
    • getSupportedMediaTypes

      protected List<MediaType> getSupportedMediaTypes(Class<?> clazz)
      Return the media types supported by all provided message converters sorted by specificity via MimeTypeUtils.sortBySpecificity(List).
    • adaptArgumentIfNecessary

      @Nullable protected Object adaptArgumentIfNecessary(@Nullable Object arg, cn.taketoday.core.MethodParameter parameter)
      Adapt the given argument against the method parameter, if necessary.
      参数:
      arg - the resolved argument
      parameter - the method parameter descriptor
      返回:
      the adapted argument, or the original resolved argument as-is
    • closeStreamIfNecessary

      void closeStreamIfNecessary(InputStream body)
      Allow for closing the body stream if necessary, e.g. for part streams in a multipart request.