【发布时间】:2019-01-30 07:33:35
【问题描述】:
<div class="form-group">
<label class="control-label col-md-3 col-sm-3 col-xs-12">Roles
<span class="required">*</span>
</label>
<thbody>
<td><th:block th:each="myRoles : ${MyRoles}">
<input type="checkbox" name="roles"
th:value="${myRoles .id}" checked />
<label th:text="${myRoles .roleName}"></label>
</th:block>--</td>
</thbody>
当前它只显示一个列表(当前角色),我想显示绑定在对象 ${AllRoles} 中的所有角色,并仅检查当前赋予特定用户的角色。
我正在尝试将角色保存在我的控制器中:
Set<UserRole> myRolesSet;
myRolesSet= myusr.getRoles();
这是我试图在视图中做的事情:
<thbody >
<td><th:block th:each="allRoles : ${allrole}">
<input type="checkbox" name="roles" th:value="${allRoles.id}"
th:checked="${#sets.contains(myRolesSet,allRoles.id)}? 'checked' " />
<label th:text="${allRoles.roleName}"></label>
</th:block></td>
</thbody>
【问题讨论】:
标签: java list spring-boot iterator thymeleaf