does thymeleaf support auto binding form 1:n relation?


There are two entities User, Group. Group has many users.

private Group group;

public Group getGroup() {
    return group;

public void setGroup(Group group) { = group;

private List<User> users;

public List<User> getUsers() {
    return users;

public void setUsers(List<User> users) {
    this.users = users;


<form th:object="${user}" class="form-horizontal" role="form"th:action="@{${#httpServletRequest.servletPath}}" method="post">
    <label for="group****????" class="col-sm-2 control-label">Group: </label>
    <input type="text" name="group****??????" required="required" />

I want to bind group_id automatically. But I don't know getter, setter about group and group_id and pass parameters to controller.


This video can help you solving your question :)
By: admin