我的模型课上有这个
@OneToMany(fetch = FetchType.EAGER)
@Fetch(FetchMode.SELECT)
private Set<Autorizacao> autorizacoes;
在我的html表单中,我尝试使用以下两种方法:
<div class="form-group">
<table class="table table-striped">
<tr th:each="autorizacao : ${autorizacoes}">
<td>
<input type="checkbox" name="autorizacoes" th:value="${autorizacao.id}" class="form-check-input">
</td>
<td th:text="${autorizacao}"></td>
</tr>
</table>
</div>
或
<div class="form-group">
<table class="table table-striped">
<tr th:each="autorizacao : ${autorizacoes}">
<td>
<input type="checkbox" name="autorizacoes[]" th:value="${autorizacao.id}" class="form-check-input">
</td>
<td th:text="${autorizacao}"></td>
</tr>
</table>
</div>
对于第一个,表单提交没有错误,但是没有保存任何数据(仅用于此属性)。对于第二个,提交没有结束(错误表明我需要数组,列表或映射)。
这里正确的方法是什么?