I have the following code
Errors errors = new MapBindingResult(new HashMap(), "person");
Why do we specify "person" as the second argument, when is it used?
I have the following code
Errors errors = new MapBindingResult(new HashMap(), "person");
Why do we specify "person" as the second argument, when is it used?
Its basically to pinpoint the error context. It tells the client or the end user that the errors are related to which entity , in your case person.
If you will see the default messages that spring will put for validations, they will be of the form
person.required
person.invalid
or something similar
They act as kind of namespaces