[英]Spring boot cannot find index.html under resoures folder
文件夹结构:
我无法访问资源/静态文件夹下的 test.html:
src-> main-> java-> resources -> static -> test.html
http://localhost:8080/test.html (不工作)
但能够在以下情况下访问 index.html:
src-> main-> java-> webapp-> index.html
http://localhost:8080/index.html (工作)
从 Spring Boot 文档来看,我似乎应该将所有静态内容放在 /src/main/resources/static 下
额外信息: <packaging>war</packaging>
war 文件中的 WEB-INF:
知道为什么我无法访问 test.html 吗?
您必须添加文件扩展名:“index.html”。 另一种选择(如果你想让它在没有扩展的情况下工作)是将 thymeleaf 依赖项添加到 pom.xml。
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-thymeleaf</artifactId>
</dependency>
您需要将内容实际放置在名为 static 的文件夹中。
层次结构将是 src/main/resources/static/index.html
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.