必须引入Thymeleaf依赖
<dependency> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-starter-thymeleaf</artifactId> </dependency>
在controller层编写接口
@RequestMapping("/{page}") public String getPage(@PathVariable String page){ return page; }
注:
在application文件下配置(非必须):
spring: mvc: view: prefix: /templates/ suffix: .html
thymeleaf: mode: HTML suffix: .html prefix: classpath:/templates cache: false