zoukankan      html  css  js  c++  java
  • thymeleaf 遍历使用案例

    1、语法:

    th:each属性用于迭代循环,语法:th:each="obj,iterStat:${objList}"

    迭代对象可以是List,Map,数组等;

    2、说明:iterStat称作状态变量,属性有:
        index:当前迭代对象的index(从0开始计算)
        count: 当前迭代对象的index(从1开始计算)
        size:被迭代对象的大小
        current:当前迭代变量
        even/odd:布尔值,当前循环是否是偶数/奇数(从0开始计算)
        first:布尔值,当前循环是否是第一个

        last:布尔值,当前循环是否是最后一个

    3、示例: 

    <html>
     <head></head>
     <body>
      <li>List遍历: 
       <table border="1"> 
        <tbody>
         <tr>
          <th>名称</th> 
          <th>状态变量:index</th>
       ...
    </tr> <tr th:each="user,userStat : ${userList}"> <th th:text="${user.name}">test</th> <th th:text="${userStat.index}">状态变量:index</th> ... </tr> </tbody> </table> </li> <li>Map遍历: <div th:each="map:${maps}"> <div th:text="${map}"></div> </div> </li> <li>数组遍历: <div th:each="array:${arrays}"> <div th:text="${array}"></div> </div> </li> </body> </html>     
  • 相关阅读:
    百度云人脸识别API人脸库管理
    百度云人脸识别API人脸对比
    Linux之find命令
    Linux之grep命令
    Linux之sed命令
    LNMP Shell脚本发布
    auto_modify_ip Shell脚本安装
    JVM虚拟机详解+Tomcat性能优化
    Tomcat连接器详解
    Tomcat配置详解
  • 原文地址:https://www.cnblogs.com/kingsonfu/p/9840157.html
Copyright © 2011-2022 走看看