Java Can';t使用Spring Boot提供static index.html
我是春天的新手,我发现很难进入春天。我想提供一个静态index.html,但它不起作用 我使用了教程,但无法使用以下工具访问index.html: 或 IndexHTML控制器:Java Can';t使用Spring Boot提供static index.html,java,spring,spring-mvc,Java,Spring,Spring Mvc,我是春天的新手,我发现很难进入春天。我想提供一个静态index.html,但它不起作用 我使用了教程,但无法使用以下工具访问index.html: 或 IndexHTML控制器: package de.phip1611.springboot_test_1; import org.springframework.stereotype.Controller; @Controller public class IndexHtmlController {} // due to https://sp
package de.phip1611.springboot_test_1;
import org.springframework.stereotype.Controller;
@Controller
public class IndexHtmlController {}
// due to https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot
// this should be enough..
你能试试下面的方法吗:
index.html
移动到src/main/resources/static
文件夹server.contextPath
设置为/
。(即server.contextPath=/
)我在src/main/resources/static文件夹中有一个html文件,并在下面的application.yml中添加了该文件,但它对我也不起作用。在tomcat启动时,localhost:8080显示404,网页显示白标签错误。但对于localhost:8080/hello.html,我在检查时看到200响应代码,但网页上没有html内容
server:
servlet:
context-path: /
port: 8080
server.contextPath
属性的值是多少?那是什么?未设定