0
点赞
收藏
分享

微信扫一扫

Thymeleaf中条件判断将用户对应的数字转化为对应的男和女


1、实现效果

1.1 未转化前的效果

Thymeleaf中条件判断将用户对应的数字转化为对应的男和女_代码实现

1.2 转化后的效果

Thymeleaf中条件判断将用户对应的数字转化为对应的男和女_bootstrap_02

2、代码实现

<td>
<div th:switch="${employee.gender}">
<span th:case="1">男</span>
<span th:case="0">女</span>
</div>
</td>

3、完整的table表格

使用了bootstrap

<table id="mydataTable" class="table table-hover table-striped">
<thead>
<tr>
<th>编号</th>
<th>姓名</th>
<th>邮箱</th>
<th>性别</th>
<th colspan="2">操作</th>
</tr>
</thead>
<!--查询用户处理-->
<tbody>
<tr th:each="employee : ${employeeList}">
<td th:text="${employee.id}"></td>
<td th:text="${employee.lastName}"></td>
<td th:text="${employee.email}"></td>
<td>
<div th:switch="${employee.gender}">
<span th:case="1">男</span>
<span th:case="0">女</span>
</div>
</td>
<td>
<a class="btn btn-danger btn-xs" @click="deleteEmployee"
th:href="@{'/employee/'+${employee.id}}">delete</a>
<a class="btn btn-primary btn-xs" th:href="@{'/employee/'+${employee.id}}">update</a>

</td>

</tr>
</tbody>
</table>

4、后语

这里是​​SpringMVC​​​中使用​​thymeleaf​​​模板解析、控制层使用了Model来进行数据的传输、使用了BootStrap框架
学无止境。。。。。。


举报

相关推荐

0 条评论