需求背景:在html中,当满足什么条件时,显示什么html元素,否则不显示什么元素
举个简单的th:block使用,三个按钮1和3为true,2是false,那么2中被th:block包含的代码段则不显示,效果如下图
<th:block th:if='${1==1}'>
<button class="btn btn-default" data-toggle="modal" data-target="#myModal">
<i class="fa fa-plus"></i> 新增1显示
</button>
</th:block>
<th:block th:if='${1!=1}'>
<button class="btn btn-default" data-toggle="modal" data-target="#myModal">
<i class="fa fa-plus"></i> 新增2不显示
</button>
</th:block>
<th:block th:if='${1==1}'>
<button class="btn btn-default" data-toggle="modal" data-target="#myModal">
<i class="fa fa-plus"></i> 新增3显示
</button>
</th:block>