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

Class RequestBodyAdviceAdapter

  • java.lang.Object
    • org.springframework.web.servlet.mvc.method.annotation.RequestBodyAdviceAdapter
    • Constructor Detail

      • RequestBodyAdviceAdapter

        public RequestBodyAdviceAdapter()
    • Method Detail

      • beforeBodyRead

        public HttpInputMessage beforeBodyRead(HttpInputMessage inputMessage,
                                               MethodParameter parameter,
                                               java.lang.reflect.Type targetType,
                                               java.lang.Class<? extends HttpMessageConverter<?>> converterType)
                                        throws java.io.IOException
        The default implementation returns the InputMessage that was passed in.
        Specified by:
        beforeBodyRead in interface RequestBodyAdvice
        Parameters:
        inputMessage - the request
        parameter - the target method parameter
        targetType - the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.
        converterType - the converter used to deserialize the body
        Returns:
        the input request or a new instance, never null
        Throws:
        java.io.IOException
      • afterBodyRead

        public java.lang.Object afterBodyRead(java.lang.Object body,
                                              HttpInputMessage inputMessage,
                                              MethodParameter parameter,
                                              java.lang.reflect.Type targetType,
                                              java.lang.Class<? extends HttpMessageConverter<?>> converterType)
        The default implementation returns the body that was passed in.
        Specified by:
        afterBodyRead in interface RequestBodyAdvice
        Parameters:
        body - set to the converter Object before the first advice is called
        inputMessage - the request
        parameter - the target method parameter
        targetType - the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.
        converterType - the converter used to deserialize the body
        Returns:
        the same body or a new instance
      • handleEmptyBody

        @Nullable
        public java.lang.Object handleEmptyBody(@Nullable
                                                          java.lang.Object body,
                                                          HttpInputMessage inputMessage,
                                                          MethodParameter parameter,
                                                          java.lang.reflect.Type targetType,
                                                          java.lang.Class<? extends HttpMessageConverter<?>> converterType)
        The default implementation returns the body that was passed in.
        Specified by:
        handleEmptyBody in interface RequestBodyAdvice
        Parameters:
        body - usually set to null before the first advice is called
        inputMessage - the request
        parameter - the method parameter
        targetType - the target type, not necessarily the same as the method parameter type, e.g. for HttpEntity<String>.
        converterType - the selected converter type
        Returns:
        the value to use or null which may then raise an HttpMessageNotReadableException if the argument is required.