springboot 在未配置访问静态资源的情况下,会默认到 templates 文件夹下找index页面.
我这里并没有配置访问静态资源的路径,所以出现以下报错,无法找到index.html界面如果使用properties文件作为SpringBoot的配置文件,那么按以下来配置访问静态资源
spring.resources.static-locations=classpath:/templates/,classpath:/static/page
这个配置项是告诉springboot去哪找资源。上面配置优先级的话 /templates会高于/static/page
如果使用yml或者yaml作为配置文件,那么访问静态资源的格式为
resources: static-locations: [classpath:/templates/,classpath:/static/pages]