thymeleaf种处理select,radio和文字回显的问题

select根据后台集合显示下列列表

<select class="form-control" name="parentId" >
     <option ></option>
     <option th:each="a : ${menus}"  th:text="${a.name}" th:value="${a.parentId}">
</select>

radio根据后台的值选中对应的数据

<div class="form-group form-inline">
     <div class="radio"><label><input type="radio" th:field="${user.gender}" name="gender" th:value="0">男</label></div>
     <div class="radio"><label><input type="radio" th:field="${user.gender}"  name="gender" th:value="1">女</label></div>
</div>

文字回显:例如前端要根据返回的值显示 男或女,我这里用的th:switch,其他的例如th:if没成功。

<td th:switch="${user.gender}">
       <p th:case="0">男</p>
       <p th:case="1">女</p>
       <p th:case="*">中性</p>
</td>

猜你喜欢

转载自www.cnblogs.com/super-hu/p/11814043.html