码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-11-07 19:40:55      阅读:203      评论:0      收藏:0      [点我收藏+]

标签:menus   根据   pre   bsp   sel   div   select   parentId   列表   

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>

 

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

标签:menus   根据   pre   bsp   sel   div   select   parentId   列表   

原文地址:https://www.cnblogs.com/super-hu/p/11814043.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!