thymeleaf select 多选下拉框以及回显
先看代码
<select id="role" name="role" class="form-control m-b" multiple="multiple">
<option
th:each="role:${roles}"
th:text="${role.roleName}"
th:value="${role.roleId}"
th:selected="${role.flag}"
</option>
</select>
关键是 multiple="multiple"
遍历option选项
th:each="role:${roles}"
th:text="${role.roleName}"
th:value="${role.roleId}"
回显
th:selected="${role.flag}"