mirror of
https://github.com/spring-projects/spring-framework
synced 2026-06-08 17:33:33 +00:00
Polishing in docs
See gh-36803
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
----
|
||||
|
||||
Reference in New Issue
Block a user