一.将 index.html 作为首页面
1.静态首页
springboot项目启动后,默认会到静态资源 resources->static 目录下查找index.html页面
2.动态首页
在静态资源路径找不到 index.html 文件,会到 resources->templates 目录下找 index.html
二.使用自定义 xxx.html 作为首页面
1.方法一:通过Controller控制首页
@RestController
public class IndexController {
@RequestMapping("/")
public String hello(){
System.out.println("OK");
return "test";
}
}
三.用Controller控制层返回任意html页面
1.在pom.xml文件中添加依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>