Spring mvc 当我将列表加载到表单中时,Thymeleaf没有检查值

Spring mvc 当我将列表加载到表单中时,Thymeleaf没有检查值,spring-mvc,spring-boot,thymeleaf,Spring Mvc,Spring Boot,Thymeleaf,我有一个元素列表(其中每个元素都有一个“id”和“name”),因此用户将从复选框列表中选择他们需要的元素,一旦用户选择了他想要的元素,然后我将所选值存储在DB中(这是有效的) 当我尝试将这些值加载到另一个表单(编辑目的)时,我需要加载所有可能的值,并用“检查”标记用户在创建过程中选择的值 在我的编辑表单中有以下代码,但我无法通过thymeleaf检查所选的值。你能告诉我怎么解决吗 <div class="form-group"> <label class="c

我有一个元素列表(其中每个元素都有一个“id”和“name”),因此用户将从复选框列表中选择他们需要的元素,一旦用户选择了他想要的元素,然后我将所选值存储在DB中(这是有效的)

当我尝试将这些值加载到另一个表单(编辑目的)时,我需要加载所有可能的值,并用“检查”标记用户在创建过程中选择的值

在我的编辑表单中有以下代码,但我无法通过thymeleaf检查所选的值。你能告诉我怎么解决吗

<div class="form-group">
        <label class="control-label" for="checkboxes">Samples checkboxes</label>
        <div>
            <div class="btn-group btn-toggle" data-toggle="buttons">
                <label th:each="elem : ${elements}"
                    th:for="${#ids.next('objectName.selectedElements')}"
                    class="btn btn-default"
                    th:classappend="${#lists.contains(objectName.selectedElements, elem)} ? 'active'">
                    <input type="checkbox"
                        th:field="*{objectName.selectedElements}"
                        th:text="${elem.name}"
                        th:value="${elem.id}" />
                </label>
            </div>
        </div>
    </div>

样本复选框
提前感谢,

使用
th:attr


请忽略此问题,上面的代码工作正常。问题出在selectedElements列表中,该列表没有正确加载元素。
<input th:if="${filterType == 'Unapproved'}" type="checkbox" th:attr="name=${file.id}" th:value="Approved" th:text="Approve"/>
<input th:if="${filterType == 'Unapproved'}" type="checkbox"  th:attr="name=${file.id}" th:value="Deleted" th:text="Delete"/>
<input th:if="${filterType == 'Approved'}" type="checkbox" th:attr="name=${file.id}" th:value="Unapproved" th:text="Unapprove" />
<input th:if="${filterType == 'Deleted'}" type="checkbox" th:attr="name=${file.id}" th:value="Approved" th:text="Approve" />