thymeleaf引入bootstrap失敗

2021-10-10 01:09:57 字數 777 閱讀 3427

今天在引入bootstrap的時候死活呼叫不出樣式

記錄一下踩的坑:

在head中**如下

rel=

"stylesheet"

th:href

="@"

>

th:src

="@"

>

script

>

th:src

="@"

>

script

>

明明檔案都引入了,卻還是出問題。

最終排查結果如下,css樣式中少了一句

rel=

"stylesheet"

href

="../static/css/bootstrap.min.css"

th:href

="@"

>

th:src

="@"

>

script

>

th:src

="@"

>

script

>

同時,在thymeleaf中,引入url時寫法格式應為:@

這樣可以幫助我們 自動加上那個 contextpath

server.servlet.context-path=/root
訪問路徑變了會導致訪問不到 css 和 js 檔案,使用如上寫法就不會。

使用ThymeLeaf新增和引入公共頁面

1,公共頁面提取,公共頁面一般都是頭尾,用th fragment屬性標記公共部分,屬性值用來引用 doctype html common header 我是公共頁面 我叫common page.html 判斷誰的activeuri 等於傳過來的activeuri,誰等於誰就亮 2,其他頁面引入公共頁...

Thymeleaf條件判斷

th if th if屬性求bool值,只有true的時候其所在的標籤及該標籤中的內容才會被渲染到輸出結果中 viewth if expression 對expression求值有下述規則 th unless th unless是th if的乙個相反操作,上面的例子可以改寫為 view th swi...

thymeleaf標籤總結

代表 獲取資源本地化檔案 表示從model裡面獲取 這2個可以一起用 比如 這相當於 的資源本地化檔案中的system.01內容 request th text th text 111 response th text th text 111 servletcontext th text th te...