Top Description Fields Constructors Methods
org.springframework.web.reactive.result.method.annotation

public Class ModelAttributeMethodArgumentResolver

extends HandlerMethodArgumentResolverSupport
Class Inheritance
Imports
java.lang.annotation.Annotation, java.util.Map, reactor.core.publisher.Mono, .Sinks, org.springframework.beans.BeanUtils, org.springframework.context.i18n.LocaleContext, .LocaleContextHolder, org.springframework.core.MethodParameter, .ReactiveAdapter, .ReactiveAdapterRegistry, .ResolvableType, org.springframework.lang.Nullable, org.springframework.ui.Model, org.springframework.util.Assert, .ClassUtils, org.springframework.validation.BindingResult, .Errors, org.springframework.validation.annotation.ValidationAnnotationUtils, org.springframework.web.bind.annotation.ModelAttribute, org.springframework.web.bind.support.WebExchangeBindException, .WebExchangeDataBinder, org.springframework.web.reactive.BindingContext, org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport, org.springframework.web.server.ServerWebExchange

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 @jakarta.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.

Authors
Rossen Stoyanchev, Juergen Hoeller, Sam Brannen
Since
5.0

Field Summary

Modifier and TypeField and Description
private final boolean
Inherited from org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport:
logger

Constructor Summary

AccessConstructor and Description
public
ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry
for adapting to other reactive types from and to Mono
adapterRegistry
,
boolean
if "true", non-simple method arguments and return values are considered model attributes with or without a @ModelAttribute annotation present.
useDefaultResolution
)

Class constructor with a default resolution mode flag.

Method Summary

Modifier and TypeMethod and Description
private boolean
bindingDisabled(MethodParameter parameter)

Determine if binding should be disabled for the supplied MethodParameter, based on the ModelAttribute#binding annotation attribute.

protected Mono<Void>
bindRequestParameters(WebExchangeDataBinder
the data binder instance to use for the binding
binder
,
ServerWebExchange
the current request
exchange
)

Extension point to bind the request to the target object.

protected Mono<Void>
constructAttribute(WebExchangeDataBinder
the data binder instance to use for the binding
binder
,
ServerWebExchange
the current exchange
exchange
)

Extension point to create the attribute, binding the request to constructor args.

private boolean
private Mono<WebExchangeDataBinder>
private Object
public Mono<Object>
resolveArgument(MethodParameter
the method parameter
parameter
,
BindingContext
the binding context to use
context
,
ServerWebExchange
the current exchange
exchange
)

Implements org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver.resolveArgument.

Resolve the value for the method parameter.

public boolean
supportsParameter(MethodParameter
the method parameter
parameter
)

Implements org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver.supportsParameter.

Whether this resolver supports the given method parameter.

private void
Inherited from org.springframework.web.reactive.result.method.HandlerMethodArgumentResolverSupport:
checkAnnotatedParamNoReactiveWrappercheckParameterTypecheckParameterTypeNoReactiveWrappergetAdapterRegistry

Field Detail

useDefaultResolutionback to summary
private final boolean useDefaultResolution

Constructor Detail

ModelAttributeMethodArgumentResolverback to summary
public ModelAttributeMethodArgumentResolver(ReactiveAdapterRegistry adapterRegistry, boolean useDefaultResolution)

Class constructor with a default resolution mode flag.

Parameters
adapterRegistry:ReactiveAdapterRegistry

for adapting to other reactive types from and to Mono

useDefaultResolution:boolean

if "true", non-simple method arguments and return values are considered model attributes with or without a @ModelAttribute annotation present.

Method Detail

bindingDisabledback to summary
private boolean bindingDisabled(MethodParameter parameter)

Determine if binding should be disabled for the supplied MethodParameter, based on the ModelAttribute#binding annotation attribute.

Since
5.2.15
bindRequestParametersback to summary
protected Mono<Void> bindRequestParameters(WebExchangeDataBinder binder, ServerWebExchange exchange)

Extension point to bind the request to the target object.

Parameters
binder:WebExchangeDataBinder

the data binder instance to use for the binding

exchange:ServerWebExchange

the current request

Since
5.2.6
constructAttributeback to summary
protected Mono<Void> constructAttribute(WebExchangeDataBinder binder, ServerWebExchange exchange)

Extension point to create the attribute, binding the request to constructor args.

Parameters
binder:WebExchangeDataBinder

the data binder instance to use for the binding

exchange:ServerWebExchange

the current exchange

Since
6.1
hasErrorsArgumentback to summary
private boolean hasErrorsArgument(MethodParameter parameter)
initDataBinderback to summary
private Mono<WebExchangeDataBinder> initDataBinder(String name, MethodParameter parameter, BindingContext context, ServerWebExchange exchange)
removeReactiveAttributeback to summary
private Object removeReactiveAttribute(String name, Model model)
Annotations
@Nullable
resolveArgumentback to summary
public Mono<Object> resolveArgument(MethodParameter parameter, BindingContext context, ServerWebExchange exchange)

Implements org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver.resolveArgument.

Doc from org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver.resolveArgument.

Resolve the value for the method parameter.

Parameters
parameter:MethodParameter

the method parameter

context:BindingContext

the binding context to use

exchange:ServerWebExchange

the current exchange

Returns:Mono<Object>

Mono for the argument value, possibly empty

Annotations
@Override
supportsParameterback to summary
public boolean supportsParameter(MethodParameter parameter)

Implements org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver.supportsParameter.

Doc from org.springframework.web.reactive.result.method.HandlerMethodArgumentResolver.supportsParameter.

Whether this resolver supports the given method parameter.

Parameters
parameter:MethodParameter

the method parameter

Annotations
@Override
validateIfApplicableback to summary
private void validateIfApplicable(WebExchangeDataBinder binder, MethodParameter parameter, ServerWebExchange exchange)