Skip to content

Commit 7520ffc

Browse files
feat: Make a point about the need for the form-backing bean name to match the name given at the Spring side. Closes #56
1 parent ab35b76 commit 7520ffc

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

docs/tutorials/3.1/thymeleafspring.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -860,6 +860,13 @@ Spring MVC's infrastructure:
860860
would not be.
861861
* Once inside the `<form>` tag, no other `th:object` attribute can be specified.
862862
This is consistent with the fact that HTML forms cannot be nested.
863+
* The name used in `th:object` (`seedStarter` in the example above) must match
864+
the name of the corresponding model attribute on the Spring MVC side. Unless
865+
a different name is set explicitly (e.g. via `@ModelAttribute("someName")` on
866+
the controller method parameter, or `Model#addAttribute("someName", ...)`),
867+
Spring will use the uncapitalized simple name of the command object's class
868+
as the model attribute name, so a `SeedStarter` object will by default be
869+
exposed to the view as `seedStarter`.
863870

864871

865872

0 commit comments

Comments
 (0)