【SpringBoot学习】04-th:if、th:unless、th:switch以及th:case

th:if、th:unless

在这里插入图片描述
th:if 如果值为true 则显示出该标签 否则 不显示(隐藏)
#lists.isEmpty(userList) true 集合为空
#lists.isEmpty(userList) false 集合非空

    <h3 th:if ="not ${#lists.isEmpty(userList)}">显示 出来userList非空 </h3>
   
    <h3 th:unless =" ${#lists.isEmpty(userList)}">显示 出来userList非空 </h3>

th:unless和th:if 相反

th:switch以及th:case

<div th:switch="${sex}">

    <p th:case="1"></p>
    <p th:case="${man}"></p>
    <!--均不满足 为以下值-->
    <p th:case="*">未知</p>

</div>
		map.put("sex",2);
        map.put("man",2);
发布了44 篇原创文章 · 获赞 7 · 访问量 851

猜你喜欢

转载自blog.csdn.net/ange2000561/article/details/104651288
th
8th
9th
7th
今日推荐