spring - Thymeleaf 文档中所需的字体未显示

标签 spring thymeleaf

我正在使用 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>

最佳答案

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

改变

<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' />

关于spring - Thymeleaf 文档中所需的字体未显示,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38210346/

相关文章:

java - 在检查 Spring 中的错误之前,我可以在 BindingResult 中添加值吗?

java - Marshaller 必须支持 Spring Batch 拆分作业中编码对象错误的类

java - 来自 :text nested in th:action in thymeleaf 的值

java - Spring Security 登录总是登陆一个没有消息的错误页面

java - 非服务类的 Spring AOP

java - 如何正确配置我的 SpringMVC 4 应用程序以使用 Thymeleaf?

JavaScript 不适用于 bootstrap 4 + thymeleaf

java - 将日期参数从 html 表单发送到 thymeleaf 中的 Controller

java - (SPRING) 从 postgresql 数据库获取用户信息并在 thymeleaf html 中打印

java - 为什么我的 Spring session 作用域 bean 在 session 之间共享?