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