org.springframework.web.reactive.result.method.annotation

## Class ModelAttributeMethodArgumentResolver

- java.lang.Object
- - org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport
  - - org.springframework.web.reactive.result.method.annotation.ModelAttributeMethodArgumentResolver

- All Implemented Interfaces:
    HandlerMethodArgumentResolver

      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`.

  Since:
    5.0
  Author:
    Rossen Stoyanchev, Juergen Hoeller, Sam Brannen

- - ### Field Summary

    - ### Fields inherited from class org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport

      `logger`

  - ### Constructor Summary

    Constructors
    Constructor and Description
    `ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry adapterRegistry, boolean useDefaultResolution)` Class constructor with a default resolution mode flag.

  - ### Method Summary

    All Methods Instance Methods Concrete Methods
    Modifier and Type | Method and Description
    --- | ---
    `protected reactor.core.publisher.Mono<Void>` | `bindRequestParameters(WebExchangeDataBinder binder, ServerWebExchange exchange)` Extension point to bind the request to the target object.
    `reactor.core.publisher.Mono<Map<String,Object>>` | `getValuesToBind(WebExchangeDataBinder binder, ServerWebExchange exchange)` Protected method to obtain the values for data binding.
    `reactor.core.publisher.Mono<Object>` | `resolveArgument(MethodParameter parameter, BindingContext context, ServerWebExchange exchange)` Resolve the value for the method parameter.
    `boolean` | `supportsParameter(MethodParameter parameter)` Whether this resolver supports the given method parameter.

    - ### Methods inherited from class org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport

      `checkAnnotatedParamNoReactiveWrapper, checkParameterType, checkParameterTypeNoReactiveWrapper, getAdapterRegistry`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### ModelAttributeMethodArgumentResolver

          public ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry adapterRegistry,
                                                      boolean useDefaultResolution)

      Class constructor with a default resolution mode flag.
      Parameters:
        `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.
      Parameters:
        `parameter` - the method parameter

    - #### resolveArgument

          public reactor.core.publisher.Mono<Object> resolveArgument(MethodParameter parameter,
                                                                     BindingContext context,
                                                                     ServerWebExchange exchange)

      Description copied from interface: `HandlerMethodArgumentResolver`
      Resolve the value for the method parameter.
      Parameters:
        `parameter` - the method parameter
        `context` - the binding context to use
        `exchange` - the current exchange
      Returns:
        `Mono` for the argument value, possibly empty

    - #### bindRequestParameters

          protected reactor.core.publisher.Mono<Void> bindRequestParameters(WebExchangeDataBinder binder,
                                                                            ServerWebExchange exchange)

      Extension point to bind the request to the target object.
      Parameters:
        `binder` - the data binder instance to use for the binding
        `exchange` - the current request
      Since:
        5.2.6

    - #### getValuesToBind

          public reactor.core.publisher.Mono<Map<String,Object>> getValuesToBind(WebExchangeDataBinder binder,
                                                                                 ServerWebExchange exchange)

      Protected method to obtain the values for data binding. By default this method delegates to `WebExchangeDataBinder.getValuesToBind(org.springframework.web.server.ServerWebExchange)`.
      Parameters:
        `binder` - the data binder in use
        `exchange` - the current exchange
      Returns:
        a map of bind values
      Since:
        5.3