【发布时间】:2019-12-19 20:20:47
【问题描述】:
我需要在电子邮件模板 (thymeleaf) 中插入样式。我需要为几个模板制作一个通用的 css 文件。
使用spring boot 1.3.3
我尝试关注以下帖子中的内容: Thymeleaf + CSS+SpringBoot
电子邮件文件:资源 > 邮件 > “email.html” css 文件:资源 > 静态 > css > "styles.css"
我对邮件使用 WebContext(我曾经使用 Context,但是 Context 不接受相对路径,并且需要 WebContext)。
在我的 CSS 中:
h1 {
color: #78ab46;
}
在我的模板中:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
<title > Hello </title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<link rel="stylesheet" type="text/css" media="all"
href="../static/css/styles.css" th:href="@{/css/styles.css}" />
</head>
<body>
<h1> Hello </h1>
</body>
结果是发送了邮件但没有考虑css样式。我也没有看到任何错误消息。
你能帮帮我吗?
谢谢,
曼努埃拉
【问题讨论】: