Skip to content

Commit ca32ac5

Browse files
committed
Polishing in docs
See gh-36803
1 parent 63ccc9d commit ca32ac5

1 file changed

Lines changed: 14 additions & 3 deletions

File tree

framework-docs/modules/ROOT/partials/web/web-data-binding-model-design.adoc

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ For example:
2828
}
2929
----
3030

31-
32-
3331
NOTE: It is also possible to configure `disallowedFields`, but that's fragile, and
3432
due to be https://github.com/spring-projects/spring-framework/issues/36802[deprecated] in Spring Framework 7.1.
3533
It is easy to miss or add others over time that should also be excluded.
@@ -38,4 +36,17 @@ By default, `DataBinder` applies both constructor and setter binding.
3836
This is fine with immutable objects and dedicated objects, but for domain objects, you must
3937
remember to declare `allowFields`. To ensure data binding is only used in declarative style where
4038
expected inputs are explicitly declared, you can set `declarativeBinding=true` on `DataBinder`.
41-
In this mode, `DataBinding` applies constructor binding, and additionally setter binding if `allowedFields` is set.
39+
In this mode, `DataBinding` applies constructor binding, and additionally setter binding if `allowedFields` is set.
40+
The below shows how to set this flag globally:
41+
42+
[source,java,indent=0,subs="verbatim,quotes"]
43+
----
44+
@ControllerAdvice
45+
public class ControllerConfig {
46+
47+
@InitBinder
48+
void initBinder(WebDataBinder binder) {
49+
binder.setDeclarativeBinding(true);
50+
}
51+
}
52+
----

0 commit comments

Comments
 (0)