【发布时间】:2020-11-21 06:51:01
【问题描述】:
我在 docker 上查找 thymeleaf 模板时遇到问题。我熟悉普通控制器中的leading slash problem。不过,我现在想使用 thymeleaf 来呈现电子邮件正文。
我的代码如下所示:
@Component
public class HtmlEmailDocumenter implements Documenter {
@Autowired
SpringTemplateEngine thymeleafTemplateEngine;
// more dependencies
@Override
public void accept(Documentable documentable){
Context thymeleafContext = new Context();
thymeleafContext.setVariable("doc", documentable);
String template = "mail/default";
String htmlBody = thymeleafTemplateEngine.process(template, thymeleafContext);
// send the email...
}
}
有问题的模板位于/src/main/resources/templates/mail/default.html 下。我也曾尝试在源代码中使用“mail/default.html”。在 docker 中也不起作用。
欢迎任何提示。
【问题讨论】:
标签: java spring spring-boot docker thymeleaf