1
我見過的問題與建議將絕對路徑轉換爲相對路徑的答案,但這對我來說是不可能的,因爲我的HTML文件存儲在各種目錄中並使用一行代表CSS的模板。所以fragments.html
開始是這樣的:Thymeleaf:在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 th:fragment="common_header(title)">
<link rel="stylesheet" th:href="@{/css/style.css}" />
:
實際的HTML看起來像
<!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 th:replace="fragments :: common_header('List Items')">
<title>Main</title>
</head>
<body>
<script th:src="@{/js/rss/list.js}"></script>
:
現在/css/style.css
:
.item-subject::before {
content: url("/images/new.png");
margin-right: 5px;
}
隨着上下文路徑和所有很明顯,這不起作用。但我能做什麼呢?我的意思是th:href
使得link
指向一個有效的資源,所以現在CSS的內容也應該以某種方式來保存。
很明顯,content
-line必須包含魔法,但我該如何做所有這些工作?
哦不,Spring-Boot不使用Thymeleaf 3 ... – sjngm