首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >从外部Url加载Freemarker模板

从外部Url加载Freemarker模板
EN

Stack Overflow用户
提问于 2019-06-13 20:29:29
回答 1查看 1.4K关注 0票数 2

我已经实现了spring boot应用程序,我们需要使用freemarker发送电子邮件。应用程序将部署在google应用程序引擎上,其中文件结构不可用于存储模板。因此,我将模板保存在具有公共访问权限的google存储上。但不能在freemarker模板引擎中加载。

代码语言:javascript
复制
freeMarkerConfiguration.setDirectoryForTemplateLoading(new File("/home/dnilesh/Downloads/helloworld-springboot/src/main/resources/"));

content.append(FreeMarkerTemplateUtils.processTemplateIntoString(
                freeMarkerConfiguration.getTemplate("Email.html"),model));

上面的配置将在开发环境下工作。但在谷歌应用程序引擎上,我没有目录来存储模板。

我试过这个:

代码语言:javascript
复制
freeMarkerConfiguration.setDirectoryForTemplateLoading(new File("https://storage.googleapis.com/nixon-medical/"));

           content.append(FreeMarkerTemplateUtils.processTemplateIntoString(
                    freeMarkerConfiguration.getTemplate("Email.html"),model));

但是freemarker没有从外部URL加载模板。我如何加载这个?

EN

回答 1

Stack Overflow用户

发布于 2019-06-14 03:17:02

您可以使用Thymeleaf解析器加载外部文件。https://www.thymeleaf.org/doc/tutorials/2.1/thymeleafspring.html

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/56580519

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档