thymeleaf 之 th:each迭代循环对象集合
th:each属性用于迭代循环,语法:th:each="obj,iterStat:${objList}"
迭代对象可以是java.util.List,java.util.Map,数组等;
iterStat称作状态变量,属性有:
index:当前迭代对象的index(从0开始计算)
count: 当前迭代对象的index(从1开始计算)
size:被迭代对象的大小
current:当前迭代变量
even/odd:布尔值,当前循环是否是偶数/奇数(从0开始计算)
first:布尔值,当前循环是否是第一个
last:布尔值,当前循环是否是最后一个
- <ol>
- <li>List循环:
- <table border="1">
- <tr>
- <th>用户名</th>
- <th>邮箱</th>
- <th>管理员</th>
- <th>状态变量:index</th>
- <th>状态变量:count</th>
- <th>状态变量:size</th>
- <th>状态变量:current.userName</th>
- <th>状态变量:even</th>
- <th>状态变量:odd</th>
- <th>状态变量:first</th>
- <th>状态变量:last</th>
- </tr>
- <tr th:each="user,userStat : ${list}">
- <td th:text="${user.userName}">Onions</td>
- <td th:text="${user.email}">test@test.com.cn</td>
- <td th:text="${user.isAdmin}">yes</td>
- <th th:text="${userStat.index}">状态变量:index</th>
- <th th:text="${userStat.count}">状态变量:count</th>
- <th th:text="${userStat.size}">状态变量:size</th>
- <th th:text="${userStat.current.userName}">状态变量:current</th>
- <th th:text="${userStat.even}">状态变量:even****</th>
- <th th:text="${userStat.odd}">状态变量:odd</th>
- <th th:text="${userStat.first}">状态变量:first</th>
- <th th:text="${userStat.last}">状态变量:last</th>
- </tr>
- </table>
- </li>
- <li>Map循环:
- <div th:each="mapS:${map}">
- <div th:text="${mapS}"></div>
- </div>
- </li>
- <li>数组循环:
- <div th:each="arrayS:${arrays}">
- <div th:text="${arrayS}"></div>
- </div>
- </li>
- </ol>
thymeleaf 之 th:each迭代循环对象集合的更多相关文章
- 再谈使用Emit把Datatable转换为对象集合(List<T>)
一.前因和存在的问题 前面我写了一篇<使用Emit把Datatable转换为对象集合(List<T>)>的博文,其实起源于我自己编写的一个orm工具(见前面几篇博文有介绍),里 ...
- 使用Emit把Datatable转换为对象集合(List<T>)
Emit生成动态方法部分摘自网上,但是经过修改,加入了对委托的缓存以及类结构的调整,使之调用更简洁方便.大致的思路是:要实现转换datatable到某个指定对象的集合,本质是实现转换一个datarow ...
- C#中对象,字符串,dataTable、DataReader、DataSet,对象集合转换成Json字符串方法。
C#中对象,字符串,dataTable.DataReader.DataSet,对象集合转换成Json字符串方法. public class ConvertJson { #region 私有方法 /// ...
- 利用反射与dom4j读取javabean生成对应XML和读取XML得到对应的javabean对象集合
转自:http://blog.csdn.net/zhao19861029/article/details/8473245 首先实现生成对应的JAVAbean的XML文件方法 /** * DMO4J写入 ...
- JSON转换类(二)--List转换成Json、对象集合转换Json等
#region List转换成Json /// <summary> /// List转换成Json /// </summary> public static string Li ...
- JSon_零基础_005_将po(bean)对象集合List转换为JSon格式的对象字符串,返回给界面
将po(bean)对象集合List转换为JSon格式的对象字符串,返回给界面 导入jar包: 编写:po(bean)代码: package com.west.webcourse.po; /** * 第 ...
- List转换成Json、对象集合转换Json等
#region List转换成Json /// <summary> /// List转换成Json /// </summary> public static string Li ...
- [Json] C#ConvertJson|List转成Json|对象|集合|DataSet|DataTable|DataReader转成Json (转载)
点击下载 ConvertJson.rar 本类实现了 C#ConvertJson|List转成Json|对象|集合|DataSet|DataTable|DataReader转成Json|等功能大家先预 ...
- C#高级知识点概要(3) - 特性、自动属性、对象集合初始化器、扩展方法、Lambda表达式和Linq查询
1.特性(Attributes) 特性(Attributes),MSDN的定义是:公共语言运行时允许你添加类似关键字的描述声明,叫做attributes, 它对程序中的元素进行标注,如类型.字段.方法 ...
随机推荐
- 百度地图API 显示区域边界及地名定位
百度地图API 显示区域边界及地名定位 这个定位一共用了两个方法组成 一个是定位绘制区域边界线,另一个是地名定位 原理: 当用户输入省.市.县.区这种大地名时,我们要定位用户输入的这个位置,并显示轮廓 ...
- linux 前端部署
linux.conf user root; worker_processes ; #error_log logs/error.log; #error_log logs/error.log notice ...
- wpf中把按钮变成圆角
<Button x:Name="btn" Content="改变" Width="100" Height="50&quo ...
- hadoo异常——org.apache.hadoop.security.UserGroupInformation: PriviledgedActionException
2013-08-20 10:36:17,728 INFO org.apache.hadoop.http.HttpServer: listener.getLocalPort() returned 500 ...
- Leetcode 12
//日积月累,水滴石穿class Solution { public: string longestCommonPrefix(vector<string>& strs) { if ...
- JS BOM操作
Bom:浏览器对象模型(Browser Object Model,简称 BOM)提供了独立于内容而与浏览器窗口进行交互的对象.描述了与浏览器进行交互的方法和接口,可以对浏览器窗口进行访问和操作 (1) ...
- 011PHP文件处理——文件处理 文件内容分页操作类
<?php /** * 文件内容分页操作类: */ //访问地址:http://basicphp.com/006file/011.php?&page=1 class StrPage { ...
- 利用Sonar定制自定义JS扫描规则(三)——SSLR JavaScript Toolkit 使用说明
在上一篇blog中讲了在sonar中如何新增自定义的JS规则,这里面比较难的地方是XPath语句的编写,而要编写正确的XPath语句,首先要拿到语法的AST,下面我们就来介绍如何使用SSLR Java ...
- 关于面向对象和String类型的 09,10
package test.面试题; public class Test9 { public static void main(String[] args){ Outer.Inner in=new Ou ...
- New Concept English Two 5
$课文9 冷遇 83. On Wednesday evening, we went to the Town Hall. 星期三的晚上,我们去了市政厅. 84. It was the last day ...