# 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 开发四年只会写业务代码,分布式高并发都不会还做 ...
随机推荐
- [计算机视觉][神经网络与深度学习]Faster R-CNN配置及其训练教程2
faster-rcnn分为matlab版本和python版本,首先记录弄python版本的环境搭建过程.matlab版本见另一篇:faster-rcnn(testing): ubuntu14.04+c ...
- configparser 文件加字典操作
import configparser conf=configparser.ConfigParser() #創建一個對象 # f=open('db.ini','w') conf['DEFAULT'] ...
- 谈nginx配置
近日看<许式伟的架构课>中一段关于系统分解的描述所有思考,略记于此. 原文片段如下: 系统设计,简单来说就是 "对系统进行分解" 的能力.这个阶段核心要干的事情,就是明 ...
- Django的Xadmin使用
Django Xadmin 通常在实际的开发当中, 除了前后端分离的项目, 还有一些前后端不分离的项目, 这样我们在访问不分离的页面的时候, 就可以通过Django自带的admin管理模块来轻松实现后 ...
- Dubbo快速入门 四
4.业务场景 4.1).提出需求 某个电商系统,订单服务需要调用用户服务获取某个用户的所有地址: 我们现在 需要创建两个服务模块进行测试 模块 功能 订单服务web模块 创建订单等 用户服务servi ...
- JVM运行参数优化详细教程
获取设置的参数str的值: 常用的-X参数有以下这些: 手动调用GC执行垃圾回收操作:(-XX:+DisableExplicitGC 手动调用将会失效) 查看tomcat的进程ID: 或者:
- LOJ6300 博弈论与概率统计 组合、莫队
传送门 如果在\(0\)以下之后仍然会减分,那么最后的结果一定是\(N-M\). 注意到如果在Alice分数为\(0\)时继续输,那么就相当于减少了一次输的次数.也就是说如果说在总的博弈过程中,Ali ...
- Codeforces 1239B. The World Is Just a Programming Task (Hard Version)
传送门 这一题好妙啊 首先把括号序列转化成平面直角坐标系 $xOy$ 上的折线,初始时折线从坐标系原点 $(0,0)$ 出发 如果第 $i$ 个位置是 '(' 那么折线就往上走一步($y+1$),否则 ...
- Kubernetes1.11.1 使用Nvidia显卡配置方法
一.安装 1.1.kubernetes硬件支持问题说明 Kubernetes目前主要在很小程度上支持CPU和内存的发现.Kubelet本身处理的设备非常少.Kubernetes对于硬件都使用都依赖于硬 ...
- 封装的PKPM BimView的方法
封装的方法 var ObvApiWrapper; if (!ObvApiWrapper) { ObvApiWrapper = {}; } ObvApiWrapper = function(build, ...