SpringBoot整合Thymeleaf
2020-03-28 18:57
155 查看
SpringBoot整合Thymeleaf
- 引入依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
- 基础配置
#Thymeleaf #是否启用缓存,开发环境不建议启用,生成环境建议启用 spring.thymeleaf.cache=false spring.thymeleaf.mode=HTML spring.thymeleaf.encoding=UTF-8 spring.thymeleaf.prefix=classpath:/templates/ spring.thymeleaf.suffix=.html
- 创建模板(thymeleaf.html)
<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>Thymeleaf 模板</title> </head> <body> <h2>Thymeleaf 模板</h2> </body> </html>
- 创建Controller
/** * Author: avaos */ @Controller @RequestMapping("/thymeleaf") public class ThymeleafController { @Autowired private ServerConstant settings; @GetMapping public String index(ModelMap modelMap){ modelMap.addAttribute("settings", settings); return "thymeleaf"; }
- 测试
在浏览器中访问http://localhost/thymeleaf
- 点赞
- 收藏
- 分享
- 文章举报
相关文章推荐
- Spring Boot 2.X 学习日记——整合模板引擎(Thymeleaf)
- SpringBoot之整合Thymeleaf 因为版本问题而不能起作用
- Thymeleaf整合Springboot(idea)
- Springboot系列:Springboot与Thymeleaf模板引擎整合基础教程(附源码)
- Springboot系列:Springboot与Thymeleaf模板引擎整合基础教程(附源码)
- 【个人学习】使用idea搭建SpringBoot,整合Mybatis、Thymeleaf,连接数据库,实现具有前端界面项目:主要功能登录,注册,个人信息查看、更改,不定时更新中...
- springboot2.0整合shiro+thymeleaf+mybatis [eclipse]
- springboot系列教程(八)——整合thymeleaf、freemarker
- BabyLog SpringBoot+MyBatis+Thymeleaf+Amaze UI 整合学习
- SpringBoot整合Thymeleaf 及常用命令案例
- Springboot系列:Springboot与Thymeleaf模板引擎整合基础教程(附源码)
- Springboot系列:Springboot与Thymeleaf模板引擎整合基础教程(附源码)
- Spring Boot 整合 Thymeleaf 完整 Web 案例
- springboot整合thymeleaf
- Spring Boot 整合 Shiro+Thymeleaf过程解析
- SpringBoot2.0完美整合Mybatis并使用thymeleaf展示数据
- 6、SpringBoot整合thymeleaf
- spring-boot整合Thymeleaf
- 快速搭建springboot项目,并整合mybatis+druid以及thymeleaf模板引擎
- springboot整合thymeleaf学习