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>

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM