# Spring Boot & thymeleaf模板 使用 th:each 遍历对象数组 -生成一批html标签体
在controller中取出emps 对象数组
//1.查询所有的员工,返回列表页面
@GetMapping("/emps")
public String list(Model model){
Collection<Employee> employees = employeeDao.getAll();
//放在model请求域中
model.addAttribute("emps",employees);
//thymeleaf 默认就会拼串 //public static final String DEFAULT_PREFIX = "classpath:/templates/xxx.html";
//public static final String DEFAULT_SUFFIX = ".html";
return "emp/list";
}
在list.html中进行遍历
<tbody>
<tr th:each="emp:${emps}">
<td th:text="${emp.id}"></td>
<td th:text="${emp.lastName}"></td>
<td th:text="${emp.email}"></td>
<td th:text="${emp.gender}==1?'男':'女'"></td>
<td th:text="${emp.department.departmentName}"></td>
<td th:text="${#dates.format(emp.birth, 'yyyy-MM-dd')}"></td>
<td>
<button class="btn btn-sm btn-primary">编辑</button>
<button class="btn btn-sm btn-danger">删除</button>
</td>
</tr>
</tbody>
结果展示

# Spring Boot & thymeleaf模板 使用 th:each 遍历对象数组 -生成一批html标签体的更多相关文章
- spring boot: thymeleaf模板引擎使用
spring boot: thymeleaf模板引擎使用 在pom.xml加入thymeleaf模板依赖 <!-- 添加thymeleaf的依赖 --> <dependency> ...
- Spring Boot Thymeleaf 模板引擎的使用
Spring Boot 中可以支持很多模板引擎,Thymeleaf 是 Spring Boot 官方推荐使用的模板引擎,虽然在社区 Thymeleaf 的性能被许多人所吐糟,但这仍然不影响大量的开发人 ...
- spring boot:thymeleaf模板中insert/include/replace三种引用fragment方式的区别(spring boot 2.3.3)
一,thymeleaf模板中insert/include/replace三种引用fragment方式的区别 insert: 把整个fragment(包括fragment的节点tag)插入到当前节点内部 ...
- spring boot + thymeleaf 3 国际化
在给spring boot 1.5.6 + thymeleaf 3进行国际化时,踩了一个坑(其实不止一个). 现象: 看到了吧, 就是取值的key, 后面被加了_en_US 或 _zh_CN, 以及前 ...
- spring boot + Thymeleaf开发web项目
"Spring boot非常适合Web应用程序开发.您可以轻松创建自包含的HTTP应用.web服务器采用嵌入式Tomcat,或者Jetty等.大多数情况下Web应用程序将使用 spring- ...
- Spring boot+Thymeleaf+easyui集成:js创建组件页面报错
开发工具:Ideal 使用场景:Demo 前提: 环境:Spring boot +Thymeleaf+easyui 引入thymeleaf模板引擎 <html lang=" ...
- spring boot: freemarket模板引擎
spring boot: freemarket模板引擎 freemarket模板引擎,可以和thymeleaf模板引擎共存 pom.xml引入 <!-- Freemarket --> &l ...
- Spring Boot Thymeleaf 实现国际化
开发传统Java WEB工程时,我们可以使用JSP页面模板语言,但是在SpringBoot中已经不推荐使用了.SpringBoot支持如下页面模板语言 Thymeleaf FreeMarker Vel ...
- spring boot + thymeleaf 乱码问题
spring boot + thymeleaf 乱码问题 hellotrms 发布于 2017/01/17 15:27 阅读 1K+ 收藏 0 答案 1 开发四年只会写业务代码,分布式高并发都不会还做 ...
随机推荐
- jenkins自动化回滚阿里云k8s应用版本
jenkins 服务器需先保留着原先构建的不同版本的应用镜像 [root@jenkins sh]# docker images|grep "maintain" registry-v ...
- Netty 面试题解析
1.Netty 是什么? Netty 是一款基于 NIO(Nonblocking I/O,非阻塞IO)开发的网络通信框架,对比于 BIO(Blocking I/O,阻塞IO),他的并发性能得到了很大提 ...
- Sublime Text3安装LESS
Sublime Text3安装LESS 1.Sublime Text3利用Package Control安装LESS插件.LESS2CSS插件 2.去node官网下载node.js http://no ...
- git使用代理加快下载
git -c http.proxy=socks5://127.0.0.1:1086 clone https://github.com/.../...
- JSVC安装
执行./start-all.sh启动hadoop时报错 Starting datanodes node1: ERROR: Cannot set priority of datanode process ...
- 2.NioEventLoop的创建
NioEventLoop的创建 NioEventLoop是netty及其重要的组成部件,它的首要职责就是为注册在它上的channels服务,发现这些channels上发生的新连接.读写等I/O事件,然 ...
- RabbitMQ实战
RabbitMQ消息队列 一.Hello World 1.amqp-client客户端依赖 2.Rabbitmq类与方法 二.交换机类型 Exchange Type 1.消息轮询分发(Round Ro ...
- 【洛谷 P5017】 摆渡车(斜率优化)
题目链接 算是巩固了一下斜率优化吧. 设\(f[i]\)表示前\(i\)分钟最少等待时间. 则有\(f[i]=\min_{j=0}^{i-m}f[j]+(cnt[i]-cnt[j])*i-(sum[i ...
- Java电商项目,秒杀,抢购等高并发场景的具体场景和一些概念以及处理思路
这里我借鉴了网上其他大佬的观点: 一:高并发带来的挑战 原因:秒杀抢购会经常会带来每秒几万的高并发场景,为了更快的返回结果给用户. 吞吐量指标QPS(每秒处理请求数),假设一个业务请求响应耗时为100 ...
- 【开发工具】- Xshell工具的下载和安装
下载地址:https://www.netsarang.com/zh/free-for-home-school/ Xshell 是一个强大的安全终端模拟软件,它支持SSH1, SSH2, 以及Micro ...