Class ServletModelAttributeMethodProcessor

    • Constructor Detail

      • ServletModelAttributeMethodProcessor

        public ServletModelAttributeMethodProcessor(boolean annotationNotRequired)
        Class constructor.
        annotationNotRequired - if "true", non-simple method arguments and return values are considered model attributes with or without a @ModelAttribute annotation
    • Method Detail

      • getRequestValueForAttribute

        protected java.lang.String getRequestValueForAttribute(java.lang.String attributeName,
                                                                         NativeWebRequest request)
        Obtain a value from the request that may be used to instantiate the model attribute through type conversion from String to the target type.

        The default implementation looks for the attribute name to match a URI variable first and then a request parameter.

        attributeName - the model attribute name
        request - the current request
        the request value to try to convert, or null if none
      • getUriTemplateVariables

        protected final java.util.Map<java.lang.String,java.lang.String> getUriTemplateVariables(NativeWebRequest request)
      • createAttributeFromRequestValue

        protected java.lang.Object createAttributeFromRequestValue(java.lang.String sourceValue,
                                                                             java.lang.String attributeName,
                                                                             MethodParameter parameter,
                                                                             WebDataBinderFactory binderFactory,
                                                                             NativeWebRequest request)
                                                                      throws java.lang.Exception
        Create a model attribute from a String request value (e.g. URI template variable, request parameter) using type conversion.

        The default implementation converts only if there a registered Converter that can perform the conversion.

        sourceValue - the source value to create the model attribute from
        attributeName - the name of the attribute (never null)
        parameter - the method parameter
        binderFactory - for creating WebDataBinder instance
        request - the current request
        the created model attribute, or null if no suitable conversion found