【SpringBoot】学习笔记-Thymeleaf模板引擎
在SpringBoot项目中使用Thymeleaf模板引擎,需要在pom.xml中导入相关依赖(SpringBoot版本 2.7.2)
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
接下来我们看Thymeleaf相关的自动装配类
我们发现,视图解析器会在Resource目录下面的templates目录中查找相关匹配的文件,并且文件后缀必须为.html
结论:
只要需要使用thymeleaf,只需要导入对应的依赖就可以了,我们将html放置到我们的templates目录下