Class ModelAttributeMethodArgumentResolver

  • All Implemented Interfaces:

    public class ModelAttributeMethodArgumentResolver
    extends HandlerMethodArgumentResolverSupport
    Resolve @ModelAttribute annotated method arguments.

    Model attributes are sourced from the model, or created using a default constructor and then added to the model. Once created the attribute is populated via data binding to the request (form data, query params). Validation also may be applied if the argument is annotated with @javax.validation.Valid or Spring's own @org.springframework.validation.annotation.Validated.

    When this handler is created with useDefaultResolution=true any non-simple type argument and return value is regarded as a model attribute with or without the presence of an @ModelAttribute.

    Rossen Stoyanchev, Juergen Hoeller
    • Constructor Detail

      • ModelAttributeMethodArgumentResolver

        public ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry adapterRegistry,
                                                    boolean useDefaultResolution)
        Class constructor with a default resolution mode flag.
        adapterRegistry - for adapting to other reactive types from and to Mono
        useDefaultResolution - if "true", non-simple method arguments and return values are considered model attributes with or without a @ModelAttribute annotation present.
    • Method Detail

      • supportsParameter

        public boolean supportsParameter(MethodParameter parameter)
        Description copied from interface: HandlerMethodArgumentResolver
        Whether this resolver supports the given method parameter.
        parameter - the method parameter
      • resolveArgument

        public reactor.core.publisher.Mono<java.lang.Object> resolveArgument(MethodParameter parameter,
                                                                             BindingContext context,
                                                                             ServerWebExchange exchange)
        Description copied from interface: HandlerMethodArgumentResolver
        Resolve the value for the method parameter.
        parameter - the method parameter
        context - the binding context to use
        exchange - the current exchange
        Mono for the argument value, possibly empty