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

Class AbstractMessageConverterMethodArgumentResolver

  • java.lang.Object
    • org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver
    • Field Detail

      • logger

        protected final Log logger
      • allSupportedMediaTypes

        protected final java.util.List<MediaType> allSupportedMediaTypes
    • Constructor Detail

      • AbstractMessageConverterMethodArgumentResolver

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

        public AbstractMessageConverterMethodArgumentResolver(java.util.List<HttpMessageConverter<?>> converters,
                                                              @Nullable
                                                              java.util.List<java.lang.Object> requestResponseBodyAdvice)
        Constructor with converters and Request~ and ResponseBodyAdvice.
        Since:
        4.2
    • Method Detail

      • readWithMessageConverters

        @Nullable
        protected <T> java.lang.Object readWithMessageConverters(HttpInputMessage inputMessage,
                                                                           MethodParameter parameter,
                                                                           java.lang.reflect.Type targetType)
                                                                    throws java.io.IOException,
                                                                           HttpMediaTypeNotSupportedException,
                                                                           HttpMessageNotReadableException
        Create the method argument value of the expected parameter type by reading from the given HttpInputMessage.
        Type Parameters:
        T - the expected type of the argument value to be created
        Parameters:
        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>.
        Returns:
        the created method argument value
        Throws:
        java.io.IOException - if the reading from the request fails
        HttpMediaTypeNotSupportedException - if no suitable message converter is found
        HttpMessageNotReadableException
      • isBindExceptionRequired

        protected boolean isBindExceptionRequired(WebDataBinder binder,
                                                  MethodParameter parameter)
        Whether to raise a fatal bind exception on validation errors.
        Parameters:
        binder - the data binder used to perform data binding
        parameter - the method parameter descriptor
        Returns:
        true if the next method argument is not of type Errors
        Since:
        4.1.5
      • adaptArgumentIfNecessary

        @Nullable
        protected java.lang.Object adaptArgumentIfNecessary(@Nullable
                                                                      java.lang.Object arg,
                                                                      MethodParameter parameter)
        Adapt the given argument against the method parameter, if necessary.
        Parameters:
        arg - the resolved argument
        parameter - the method parameter descriptor
        Returns:
        the adapted argument, or the original resolved argument as-is
        Since:
        4.3.5