Polishing in docs

See gh-36803
This commit is contained in:
rstoyanchev
2026-05-14 16:41:35 +01:00
parent 63ccc9d9cc
commit ca32ac5e7f
@@ -28,8 +28,6 @@ For example:
}
----
NOTE: It is also possible to configure `disallowedFields`, but that's fragile, and
due to be https://github.com/spring-projects/spring-framework/issues/36802[deprecated] in Spring Framework 7.1.
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.
This is fine with immutable objects and dedicated objects, but for domain objects, you must
remember to declare `allowFields`. To ensure data binding is only used in declarative style where
expected inputs are explicitly declared, you can set `declarativeBinding=true` on `DataBinder`.
In this mode, `DataBinding` applies constructor binding, and additionally setter binding if `allowedFields` is set.
In this mode, `DataBinding` applies constructor binding, and additionally setter binding if `allowedFields` is set.
The below shows how to set this flag globally:
[source,java,indent=0,subs="verbatim,quotes"]
----
@ControllerAdvice
public class ControllerConfig {
@InitBinder
void initBinder(WebDataBinder binder) {
binder.setDeclarativeBinding(true);
}
}
----