springboot用controller跳转html页面
因为SpringBoot是集成了tomcat的,步骤:
- 1.在maven工程的resources目录下的templates目录下,放入html文件
- 2.pom.xml文件依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
//一定要记得引入thymeleaf模板引擎哦
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
-
controller代码
@Controller public class HelloControl { @GetMapping("/") public String index(){ return "index"; } }