【问题标题】:Bootstrap is not loading (Thymeleaf)引导程序未加载(Thymeleaf)
【发布时间】:2018-07-10 23:23:16
【问题描述】:

使用此代码时不会加载样式:

<div class="container">     
    <div class="w-50">  
        <div class="border border-info"> 
            <div><h3 class="font-weight-bold" th:text="${post.title}"></h3></div >          
            <div><span>Category: </span><span th:text="${post.category}"></span></div>
            <div  th:text="${post.content}"></div >
            <div><span>Author: </span><span  th:text="${post.signature}"></span></div >     
            <div  th:text="${#dates.format(post.date, 'dd-MM-yyyy')}"></div >                   
        </div>
    </div>
</div>

具有以下代码页面正确加载:

<div class="container">     
    <div class="w-50">              
        <div class="border border-info" >
            <div><h3 class="font-weight-bold" ></h3></div >         
            <div><span>Category: </span><span ></span></div>
            <div  ></div >
            <div><span>Author: </span><span></span></div >      
            <div  ></div >      
    </div>
    </div>
</div>

有人可以帮忙看看这里的对象有什么问题吗?

【问题讨论】:

  • 您能定义不加载样式的含义吗?您是说您没有看到应用引导样式或样式表无法加载?
  • 样式未应用
  • 样式表的链接是什么样子的?

标签: twitter-bootstrap spring-boot thymeleaf


【解决方案1】:

问题可能是因为您没有使用 Thymleaf 的语法来链接样式表。

尝试改变:

<link rel="stylesheet" type="text/css" href="webjars/bootstrap/4.0.0-beta.2/css/bootstrap.min.css" /> 

到:

<link rel="stylesheet" type="text/css" th:href="@{/webjars/bootstrap/4.0.0-beta.2/css/bootstrap.min.css}" />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-23
    • 1970-01-01
    • 1970-01-01
    • 2014-10-03
    • 2021-04-17
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多