1、pom引入
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency
2、application.properties按需配置
与thymeleaf相关的常用配置
springboot默认resources下的static中放静态资源(如图片、静态页面),可以直接访问如 http://ip:port/静态资源即可访问
而thymeleaf模板引擎页面默认是放在resources的templates下
因为有很多都是默认配置都可以直接使用的,所以我省事在我的application.properties中都采用了默认配置,没有配什么其他东西,只要注意文件路径放正确即可,我在做的过程中先把html放在了static文件夹下,就提示Error resolving template [invite], template might not exist or might not be accessible by any of the configured Template Resolvers这样的错误
3.controller
4、html页面
th其他具体的语法,可自行百度。下图只截取了H5部门页面用来说明问题
具体路径关系:
注:页面中引用的静态图片我是放在static下的,我原本想和模板html都放在templates下,但是无法正常显示,所以请注意资源路径。
5、最终效果