springboot第七天

th:each迭代,有多少个key就迭代多少次
<tr th:each="user:${list对象}
<td th:text="${list对象的key}
<td th:text="${list对象的value}

如果只需要遍历出key
<li th:each="user : ${list对象}" th:text="${list对象的key}"></li>

user是第一个值,也有第二个值iterStat,(这里只是举例,名字随便取),第二个值有以下属性
index : 当前迭代下标 0 开始
            count : 当前迭代下标 1 开始
            size  : 获取总记录数
            current : 当前迭代出的对象
            even/odd : 当前迭代是偶数还是奇数 (1开始算,返回布尔值)
            first : 当前是否为第一个元素
            last : 当前是否为最后一个元素

总结:第二个值主要是可以得到记录数,奇偶数这些遍历出来记录的属性

th:if  动态判断,来决定显不显示标签内容

<h3 th:if="not ${#lists.isEmpty(list对象)}">显示出来说明不空</h3>

th:switch  动态指向

<div th:switch="${map的key}">
       <P th:case="1">value1</P>
       <P th:case="2">value2</P>

th:utext
可以不转义特殊字符,展现它的效果

th:Object  可以直接取出对象


开发环境中使用thymeleaf的热部署
依赖:
<dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        </dependency>

properties里
springspring.thymeleaf.cache=false

热部署需要写完后按ctrl+F9

html
<tr  行
   <td  单元格
   <th  加粗字体单元格
<ul  无序列表
   <li   列表项
<hr  横线
  <h3 标题标签 
<br   换行符
 

发布了97 篇原创文章 · 获赞 11 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/programmer188/article/details/104469783