Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/12.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.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
Spring引导:无法解析静态内容_Spring_Spring Boot - Fatal编程技术网

Spring引导:无法解析静态内容

Spring引导:无法解析静态内容,spring,spring-boot,Spring,Spring Boot,如何使用spring boot解析静态内容路径?应用程序无法定位以下css。我需要实现addResourceHandlers方法吗?还是spring boot提供了简单的配置 <link rel="stylesheet" href="../static/css/sghome.css" /> 无需使用相对路径。请使用以下内容: <link rel="stylesheet" href="css/sghome.css" /> 实际上,Spring将静态/(或公共/)和

如何使用spring boot解析静态内容路径?应用程序无法定位以下css。我需要实现addResourceHandlers方法吗?还是spring boot提供了简单的配置

<link rel="stylesheet" href="../static/css/sghome.css" />


无需使用相对路径。请使用以下内容:

<link rel="stylesheet" href="css/sghome.css" />


实际上,Spring将静态/(或公共/)和模板/映射到根目录。两者之间的主要区别在于,templates/用于动态模板(thymeleaf、velocity,…),而另一个用于静态资源(CSS、JS、图像,…),但您可以像使用同一文件夹一样使用它们。@g00glen00b感谢您的解释。