JAVA全系列 教程
3762个小节阅读:7088.5k
目录
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
准备数据
xxxxxxxxxx
Map<String,Users> map = new HashMap<>();
map.put("user1",new Users("1","shangxuetang",23));
map.put("user2",new Users("2","baizhan",22));
map.put("user3",new Users("3","admin",25));
model.addAttribute("map",map);
遍历map
xxxxxxxxxx
<table border="1" width="50%">
<tr>
<th>ID</th>
<th>Name</th>
<th>Age</th>
<th>Key</th>
</tr>
<!-- 遍历出的是一个键值对对象,key获取键,value获取值 -->
<tr th:each="m : ${map}">
<td th:text="${m.value.id}"></td>
<td th:text="${m.value.name}"></td>
<td th:text="${m.value.age}"></td>
<td th:text="${m.key}"></td>
</tr>
</table>
1. 在Thymeleaf中,遍历Map集合时,遍历出的每一项是
A map的键
B map的值
C 键值对
D 状态变量
1=>C