Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java Can';t使用Spring Boot提供static index.html_Java_Spring_Spring Mvc - Fatal编程技术网

Java Can';t使用Spring Boot提供static index.html

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

我是春天的新手,我发现很难进入春天。我想提供一个静态index.html,但它不起作用

我使用了教程,但无法使用以下工具访问index.html: 或

IndexHTML控制器:

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
    文件夹
  • 在spring boot的application.properties文件中,将
    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
    属性的值是多少?那是什么?未设定