我有这显示在UI有一个复选框上GET
请求记录列表绑定在POST对象列表。 春天开机:如何thymleaf
@GetMapping("/list")
public String list(Model model) {
model.addAttribute("records", createRecords());
return "list";
}
这是我Record
POJO
:
class Record{
private boolean selected;
private Integer id;
private String name;
private String phone;
//....
我显示在用户界面如下:
<th:block th:each = "record : ${records}">
<tr>
<td><input type="checkbox" th:field="*{selected}" th:checked="${record.selected}" /></td>
<td th:field="*{id}" th:text="${record.id}" />
<td th:field="${name}" th:text="${record.name}" />
<td th:field="${phone}" th:text="${record.phone}" />
</tr>
</th:block>
我有很难得到日对POST
从UI
选定的记录êList
。我只从POST
得到一个对象。
我想在POST
映射是这样的:
@PostMapping("/list")
public String select(@ModelAttribute ArrayList<Record> records) {
//... at least ids of selected records
//... or all the records back with selected
请帮助。
这可能是https://stackoverflow.com/questions/36500731/how-to-bind-an-object-list-with-thymeleaf的副本。 – ben3000
@ ben3000我有使用相同的对象,而不是使用具有主要对象列表包装对象的限制。 –