@@ -27,15 +27,20 @@ The target class should have a single public constructor or a single non-public
27
27
with arguments. If there are multiple constructors, then a default constructor if present
28
28
is used.
29
29
30
- By default, constructor parameter names are used to look up argument values, but you can
31
- configure a `NameResolver`. Spring MVC and WebFlux both rely to allow customizing the name
32
- of the value to bind through an `@BindParam` annotation on constructor parameters.
30
+ By default, argument values are looked up via constructor parameter names. Spring MVC and
31
+ WebFlux support a custom name mapping through the `@BindParam` annotation on constructor
32
+ parameters or fields if present. If necessary, you can also configure a `NameResolver` on
33
+ `DataBinder` to customize the argument name to use.
33
34
34
35
xref:beans-beans-conventions[Type conversion] is applied as needed to convert user input.
35
36
If the constructor parameter is an object, it is constructed recursively in the same
36
37
manner, but through a nested property path. That means constructor binding creates both
37
38
the target object and any objects it contains.
38
39
40
+ Constructor binding supports `List`, `Map`, and array arguments either converted from
41
+ a single string, e.g. comma-separated list, or based on indexed keys such as
42
+ `accounts[2].name` or `account[KEY].name`.
43
+
39
44
Binding and conversion errors are reflected in the `BindingResult` of the `DataBinder`.
40
45
If the target is created successfully, then `target` is set to the created instance
41
46
after the call to `construct`.
@@ -90,13 +95,12 @@ details. The below table shows some examples of these conventions:
90
95
| Indicates the nested property `name` of the property `account` that corresponds to
91
96
(for example) the `getAccount().setName()` or `getAccount().getName()` methods.
92
97
93
- | `account [2]`
98
+ | `accounts [2]`
94
99
| Indicates the _third_ element of the indexed property `account`. Indexed properties
95
100
can be of type `array`, `list`, or other naturally ordered collection.
96
101
97
- | `account[COMPANYNAME]`
98
- | Indicates the value of the map entry indexed by the `COMPANYNAME` key of the `account` `Map`
99
- property.
102
+ | `accounts[KEY]`
103
+ | Indicates the value of the map entry indexed by the `KEY` value.
100
104
|===
101
105
102
106
(This next section is not vitally important to you if you do not plan to work with
0 commit comments