The name given to the form-backing bean variable used in <form th:object="${someBean} ...> should match the name assigned by Spring at the controller side, either because the name of the class matches:
@RequestMapping("/do")
public String something(final SomeBean form, final Errors errors) {
...
}
...or because a @ModelAttribute annotation has been added to force that name to be the one used:
@RequestMapping("/do")
public String something(@ModelAttribute("someBean") final Form form, final Errors errors) {
...
}
Failing to do so will result in Thymeleaf being unable to detect bean validation errors at the view side. See thymeleaf/thymeleaf-spring#169.
However, this is not mentioned in the documentation (though it is done at the STSM example application). We should mention it explicitly somehow.
The name given to the form-backing bean variable used in
<form th:object="${someBean} ...>
should match the name assigned by Spring at the controller side, either because the name of the class matches:...or because a
@ModelAttribute
annotation has been added to force that name to be the one used:Failing to do so will result in Thymeleaf being unable to detect bean validation errors at the view side. See thymeleaf/thymeleaf-spring#169.
However, this is not mentioned in the documentation (though it is done at the STSM example application). We should mention it explicitly somehow.