用户,组有两个实体。 集团有很多用户。
User.java
@ManyToOne
@JoinColumn(name="group_id")
private Group group;
public Group getGroup() {
return group;
}
public void setGroup(Group group) {
this.group = group;
}
Group.java
@OneToMany(mappedBy="group")
private List<User> users;
public List<User> getUsers() {
return users;
}
public void setUsers(List<User> users) {
this.users = users;
}
form.html
<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" />
...</form>
我想自动绑定group_id。 但我不知道getter,setter about group和group_id 并将参数传递给控制器。