1.目录结构
2.pom.xml引入静态资源
org.springframework.boot
spring-boot-maven-plugin
src/main/resources
**/*.xml
**/*.properties
**/*.html
**/*.css
**/*.js
true
3.添加视图配置# view
spring.mvc.static-path-pattern=/static/**
spring.resources.static-locations=classpath:/static, classpath:/templates
spring.mvc.view.suffix=.html
静态资源统一以/static开头;
静态资源在static和templates目录中;
视图以 .html 结尾;
4.在Controller中添加RequestMapping@RequestMapping("/index")
public String index() {
return "index";
}
5.浏览器访问http://127.0.0.1:8080/static/index.html