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
Spring boot css在浏览器中为空_Spring_Spring Mvc_Spring Boot - Fatal编程技术网

Spring boot css在浏览器中为空

Spring boot css在浏览器中为空,spring,spring-mvc,spring-boot,Spring,Spring Mvc,Spring Boot,嗨,我有一个简单的spring boot web应用程序 我试图弄明白为什么我的css在浏览器中显示为空 我很确定这和资源的配置有关,但是Spring的变化太大了,所有旧的帖子都把我搞糊涂了 有人能告诉我要正确加载css需要做什么吗 <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org" xmlns:sec="http://www.t

嗨,我有一个简单的spring boot web应用程序

我试图弄明白为什么我的css在浏览器中显示为空

我很确定这和资源的配置有关,但是Spring的变化太大了,所有旧的帖子都把我搞糊涂了

有人能告诉我要正确加载css需要做什么吗

<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:th="http://www.thymeleaf.org"
      xmlns:sec="http://www.thymeleaf.org/thymeleaf-extras-springsecurity3">
    <head>
        <title>Dashboard</title> 
        <link rel="stylesheet" th:href="@{public/style.css}" href="../public/style.css"/>
        <link rel="stylesheet" th:href="@{public/bootstrap.css}" href="../public/bootstrap.css"/>
    </head>
    <body>
        <h1 th:inline="text">My Custom CMS Dashboard</h1>

        <a href="/addNewPost"><button class="btn btn-primary"> Add new Post </button></a>

    </body>
</html>

您是否为静态资源添加了任何AddResourceHandler。你能在这里补充一下吗?嗨,不,谢谢你的评论。我是一个spring新手,所以我不知道我必须这么做……但是我在哪里可以找到这个LOLL的非弃用示例?你的application.properties(或yml)是什么样子?@pinkiewirl我更新了这个问题,并包括了我的application.properties
#h2
spring.h2.console.enabled = true
spring.h2.console.path=/h2
#Datasource
spring.datasource.url=jdbc:h2:file:~/cms_db
spring.datasource.username=sa
spring.datasource.password=admin
spring.datasource.driver-class-name=org.h2.Driver

server.error.whitelabel.enabled=false


spring.resources.add-mappings=true