java - Thymeleaf CSS 未加载

标签 java spring-boot thymeleaf

我知道类似的问题已发布数百次。但我找不到类似的东西。

我的基于 thymeleaf 的网页不加载静态内容。应用程序在 Spring Boot 上运行。 html 中声明的路径有问题吗?

在我的资源路径下面:

-resources
--static
---css
---img 
---js 
---etc.

以及页面头部的示例:

<head>
        <meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <link rel="icon"  th:href="@{/img/express-favicon.png}" type="image/x-icon" />
        <title>RedCaynne Re</title>
        <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css">

        <link  th:href="@{/vendors/material-icon/css/materialdesignicons.min.css}" rel="stylesheet">
        <link  th:href="@{/css/font-awesome.min.css}" rel="stylesheet">
        <link th:href="@{/vendors/linears-icon/style.css}" rel="stylesheet">
        <link  th:href="@{/css/bootstrap.min.css}" rel="stylesheet">

        <link  th:href="@{/vendors/revolution/css/settings.css}" rel="stylesheet">
        <link th:href="@{/vendors/revolution/css/layers.css}" rel="stylesheet">
        <link th:href="@{/vendors/revolution/css/navigation.css}" rel="stylesheet">

        <link th:href="@{/vendors/bootstrap-selector/bootstrap-select.css}" rel="stylesheet">
        <link th:href="@{/vendors/bootatrap-date-time/bootstrap-datetimepicker.min.css}" rel="stylesheet">
        <link th:href="@{/vendors/owl-carousel/assets/owl.carousel.css}" rel="stylesheet">

        <link  th:href="@{/css/style.css}" rel="stylesheet">
        <link  th:href="@{/css/responsive.css}" rel="stylesheet">

        <script src="https://oss.maxcdn.com/html5shiv/3.7.3/html5shiv.min.js"></script>
        <script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
    </head> 

最佳答案

OP 代码工作正常。

代码详情请参阅https://github.com/srikantha2/jm (这是从你的操作代码中 fork 出来的)

enter image description here

关于java - Thymeleaf CSS 未加载,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59847906/

相关文章:

spring - 使用 thymeleaf 3 处理字符串模板

java - 如何从下拉框中获取用户选择的值并将其添加到模型中?

java - EL1008E : Property or field 'content' cannot be found on object of type 'java.util.ArrayList' - maybe not public or not valid?

java - Android fragment z 索引覆盖

java - 反序列化包含任意名称和数据类型的 JSON 元素

java - 如何使用 Eclipse 工作区作业等详细信息按钮实现 Eclipse 进度条

java - Tomcat上Spring Boot应用程序启动报错(数据源实例化失败)

spring-boot - spring boot gradle任务 "bootBuildImage"构建的cloudfoundry buildpack docker镜像中的语言环境和编码如何设置

java - 如何在 NetBeans 中创建一个 exe?

java - 使用 SOAP 响应始终为 null Spring Boot