我有一个布尔值矩阵(数组数组),我想在表单中显示,然后在更改后提交。 我有这个问题,我没有更多的想法,为什么它不工作。 有人可以给我一个建议吗?BindingResult和bean名称'matrix [0] [0]'的无格式目标对象都不作为请求属性
我的控制器:
@Controller
@RequestMapping(value = "/konfiguration")
public class VerteilungController {
@ModelAttribute("matrix")
public List<List<Boolean>> getVerteilungenMatrix() {
List<List<Boolean>> result2 = new ArrayList<>();
for (int i = 0; i < kategorien.size(); i++) {
result2.add(new ArrayList<>());
}
//...
return result2;
}
@RequestMapping(value = "/verteilung", method = RequestMethod.GET)
public String showPage(Model model) {
model.addAttribute("matrix", getVerteilungenMatrix());
return "konfiguration/verteilung";
}
}
形式:
<form id="verteilung_form" class="form-horizontal" method="post" action="/verteilung"
th:action="@{/konfiguration/verteilung}"
th:object="${matrix}">
<table class="table-hover">
<tr th:each="row: ${matrix}">
<td th:each="value: ${row}">
<input type="checkbox" th:field="${matrix[__${rowStat.index}__][__${valueStat.index}__]}"/>
</td>
</tr>
</table>
<div >
<button th:text="#{button.save}" class="btn btn-default" type="submit" name="save">Speichern</button>
<button th:text="#{button.reset}" name="reset" class="btn btn-default">Zurücksetzen</button>
</div>
</form>
Openening的页面,我得到
例外:处理器的“执行过程中的错误org.thymeleaf.spring4.processor.attr .SpringInputCheckboxFieldAttrProcessor'
而在日志
java.lang.IllegalStateException:既不BindingResult也不对bean名称纯目标对象 '矩阵[0] [0]' 可作为请求属性
什么是'kategorien'?我没有看到它的定义在任何地方。 –
这与此无关。它的大小大于零。 'result2'充满了非空的布尔值。 – Juliane