Is Spring MVC using getters and setters to set the values of ModelAttribute objects? Can you please cite me sources that says so. And if not, how could we force Spring MVC to use setters to set the properties of the model object?
Thanks.
I don't know if this really answers the question, but I found this quote in the documentation:
Command or form objects to bind request parameters to bean properties (via setters) or directly to fields, with customizable type conversion, depending on @InitBinder methods and/or the HandlerAdapter configuration. ... The ModelAttribute annotation can be used on a method argument to customize the model attribute name used.
This seems to imply that setters will be used if available, with direct update of the fields as a fallback.
But if you want a definitive answer, look at the source code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With