吐槽:软化版Django
一、基本流程
1、导包
<dependency> <groupId>org.thymeleaf</groupId> <artifactId>thymeleaf-spring5</artifactId> </dependency> <dependency> <groupId>org.thymeleaf.extras</groupId> <artifactId>thymeleaf-extras-java8time</artifactId> </dependency>
2、使用
a、在templates文件夹中自定义html文件
b、在controllr层->coontroller类->方法->return "文件名"
注意:不含html
3、案例(通过这种方式设置首页)
@GetMapping("/") public String getTestFirst(){ return "index"; }
二、thymeleaft语法(模板语法)
1、导入约束
xmlns:th="http://www.thymeleaf.org"
<!DOCTYPE html> <html lang="en" xmlns:th="http://www.thymeleaf.org"> <head> <meta charset="UTF-8"> <title>Title</title> </head> <body> </body> </html>
2、基础语法
参考文档
https://www.cnblogs.com/msi-chen/p/10974009.html#_label1_0
原文:https://www.cnblogs.com/wt7018/p/13347360.html