Package org.springframework.web.reactive
Class BindingContext
java.lang.Object
org.springframework.web.reactive.BindingContext
Context to assist with binding request data onto Objects and provide access
to a shared
Model with controller-specific attributes.
Provides methods to create a WebExchangeDataBinder for a specific
target, command Object to apply data binding and validation to, or without a
target Object for simple type conversion from request values.
Container for the default model for the request.
- Since:
- 5.0
- Author:
- Rossen Stoyanchev, Juergen Hoeller
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a newBindingContext.BindingContext(WebBindingInitializer initializer) Create a newBindingContextwith the given initializer. -
Method Summary
Modifier and TypeMethodDescriptioncreateDataBinder(ServerWebExchange exchange, Object target, String name) Create aWebExchangeDataBinderto apply data binding and validation with on the target, command object.createDataBinder(ServerWebExchange exchange, Object target, String name, MethodParameter parameter) Variant ofcreateDataBinder(ServerWebExchange, Object, String)with aMethodParameterfor which theDataBinderis created.createDataBinder(ServerWebExchange exchange, String name) Create aWebExchangeDataBinderwithout a target object for type conversion of request values to simple types.getModel()Return the default model.protected WebExchangeDataBinderinitDataBinder(WebExchangeDataBinder binder, ServerWebExchange exchange) Initialize the data binder instance for the given exchange.voidsetMethodValidationApplicable(boolean methodValidationApplicable) Configure flag to signal whether validation will be applied to handler method arguments, which is the case if Bean Validation is enabled in Spring MVC, and method parameters have@Constraintannotations.
-
Constructor Details
-
BindingContext
public BindingContext()Create a newBindingContext. -
BindingContext
Create a newBindingContextwith the given initializer.- Parameters:
initializer- the binding initializer to apply (may benull)
-
-
Method Details
-
getModel
Return the default model. -
setMethodValidationApplicable
public void setMethodValidationApplicable(boolean methodValidationApplicable) Configure flag to signal whether validation will be applied to handler method arguments, which is the case if Bean Validation is enabled in Spring MVC, and method parameters have@Constraintannotations.- Since:
- 6.1
-
createDataBinder
public WebExchangeDataBinder createDataBinder(ServerWebExchange exchange, @Nullable Object target, String name) Create aWebExchangeDataBinderto apply data binding and validation with on the target, command object.- Parameters:
exchange- the current exchangetarget- the object to create a data binder forname- the name of the target object- Returns:
- the created data binder
- Throws:
ServerErrorException- if@InitBindermethod invocation fails
-
initDataBinder
protected WebExchangeDataBinder initDataBinder(WebExchangeDataBinder binder, ServerWebExchange exchange) Initialize the data binder instance for the given exchange.- Throws:
ServerErrorException- if@InitBindermethod invocation fails
-
createDataBinder
Create aWebExchangeDataBinderwithout a target object for type conversion of request values to simple types.- Parameters:
exchange- the current exchangename- the name of the target object- Returns:
- the created data binder
- Throws:
ServerErrorException- if@InitBindermethod invocation fails
-
createDataBinder
public WebExchangeDataBinder createDataBinder(ServerWebExchange exchange, @Nullable Object target, String name, MethodParameter parameter) Variant ofcreateDataBinder(ServerWebExchange, Object, String)with aMethodParameterfor which theDataBinderis created. That may provide more insight to initialize theWebExchangeDataBinder.By default, if the parameter has
@Valid, Bean Validation is excluded, deferring to method validation.- Since:
- 6.1
-