- A+
所属分类:Java
---
title: thymeleaf list中的checkbox表单提交
date: 2018-08-13 13:44:15
categories:
- Spring
- thymeleaf
tags:
- list
- checkbox
- 提交
---
画面上的list中第一列为checkbox,需要传递提交整个list的值给后台。
写法如下:
前台:
<tr th:each="item, stat : *{orderInfoList}">
<td>
<label class="checkbox">
<input type="checkbox" th:field="*{orderInfoList[__${stat.index}__].check}">
</label>
.
</td>
</tr>原始的jsp里用name=orderInfoList[i].check这种形式来提交整个list,在thymeleaf里还是可以用th:field来绑定就行了,与单值一样,上面的代码,当checkbox选中时,后台接受的check的值为true,未选中时值为false。
