1.thyemleaf的默认目录是templates,如果资源在templates下面,在yml文件里面可以不用配置
2.关于yml配置的几点说明
thymeleaf: mode: LEGACYHTML5 #严格校验html语法,标签要严格按照格式去书写,比如<a> xxx</a> encoding: UTF-8 servlet: content-type: text/html #开发时关闭缓存,不然没法看到实时页面 cache: false # 在构建URL时预先查看名称的前缀 prefix: classpath: /templates/ # 构建URL时附加查看名称的后缀. suffix: .html
如果配置了 mode: LEGACYHTML5 ,需要额外配置nekohtml依赖,
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency> <!--避免没有结束标签:报错--> <dependency> <groupId>net.sourceforge.nekohtml</groupId> <artifactId>nekohtml</artifactId> <version>1.9.22</version> </dependency>