使用Thymeleaf完成数据的页面展示
概括
Thymeleaf是一种用于Web和独立环境的现代服务器端的Java模板引擎。
本文主要介绍:如何使用Thymeleaf在html页面上显示动态数据,也介绍了如何使用BootStrap文档中现成的HTML、CSS、JS进行前端开发
一、步骤截图
1. 创建SpringBoot项目,引入Thymeleaf依赖
Web场景依赖和Thymeleaf场景依赖

//thymeleaf场景依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
2. 配置Thymeleaf模板的参数

# THYMELEAF (ThymeleafAutoConfiguration)
# 开启模板缓存(默认值: true )=> 修改:开发中关闭模板页面缓存
spring.thymeleaf.cache=false
# 模板编码
spring.thymeleaf.encoding=UTF-8
# 要运⽤于模板之上的模板模式。另⻅ StandardTemplate-ModeHandlers( 默认值: HTML5)
spring.thymeleaf.mode=HTML5
# 在构建 URL 时添加到视图名称前的前缀(默认值: classpath:/templates/ )
spring.thymeleaf.prefix=classpath:/templates/
# 在构建 URL 时添加到视图名称后的后缀(默认值: .html )
spring.thymeleaf.suffix=.html
3. Controller层(Web控制层)
Controller层请求处理类:接收请求,跳转页面
突然想到访问的顺序

2418

被折叠的 条评论
为什么被折叠?



