一般资料都提3个问题
1. controller 位置不对
2. 未添加依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
3. 注释<scope>provided</scope>
<!--<dependency>--> <!--<groupId>org.apache.tomcat.embed</groupId>--> <!--<artifactId>tomcat-embed-jasper</artifactId>--> <!--<scope>provided</scope>--> <!--</dependency>-->
我的问题是 properties 要用 thymeleaf-spring5.version
<properties> <java.version>1.8</java.version> <!--自定配置开始--> <thymeleaf-spring5.version>3.0.9.RELEASE</thymeleaf-spring5.version> <thymeleaf-layout-dialect.version>2.3.0</thymeleaf-layout-dialect.version> <!--<thymeleaf.version>3.0.2.RELEASE</thymeleaf.version>--> <!--<thymeleaf-layout-dialect.version>2.1.1</thymeleaf-layout-dialect.version>--> <!--自定配置结束--> </properties>