【问题标题】:Desired font in Thymeleaf document is not shownThymeleaf 文档中所需的字体未显示
【发布时间】:2016-07-05 18:35:59
【问题描述】:

我正在使用 Thymeleaf 模板生成 HTML 页面,然后将其用作电子邮件的内容。所需的字体系列是 Calibri。但是,当生成 HTML 文档(然后作为电子邮件发送)时,检索到的包含此文档的电子邮件不包含 Calibri 中的字体。但是,如果我删除了 Thymeleaf 相关元素并在浏览器中将页面作为普通 HTML 页面启动,它确实会在 Calibri 中显示内容。有谁知道问题可能出在哪里?提前致谢!

<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
      <title></title>
      <link href='http://fonts.googleapis.com/css?family=Calibri'
      rel='stylesheet' type='text/css' />
      <style>
         body {
            font-family: 'Calibri', serif;
            font-size: 11pt;
         }
     </style>

  </head>
  <body>
    <p style="line-height:25pt;">
        We from <span th:text="${nameCompany}"></span> are sending you an email.
   </p>

 </body>
</html>

【问题讨论】:

  • 您应该使用代码的语法。有时 tyhmleaf 不接受浏览器理解的语法。
  • 您尝试过提供的解决方案吗?

标签: spring thymeleaf


【解决方案1】:

您可以尝试更改这行代码并告诉我这是否有帮助

改变

<link href='http://fonts.googleapis.com/css?family=Calibri'
      rel='stylesheet' type='text/css' />

  <link th:href="@{http://fonts.googleapis.com/css?family=Calibri}"
          rel='stylesheet' type='text/css' />

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2012-09-20
    • 2022-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-06-09
    • 2012-05-31
    相关资源
    最近更新 更多