Sure, here’s the translation: 春季 freemarker 多个模板加载器路径

huangapple go评论81阅读模式
英文:

Spring freemarker multiple template loader paths

问题

我们在我们的Spring Boot项目中使用Freemarker模板来进行电子邮件处理。

在类路径中有一个默认的目录,存储着所有基础电子邮件模板。然后,还有其他目录存储客户定制的电子邮件模板。

我们想要的是,模板加载器首先应该在客户定制目录中查找给定的电子邮件模板,如果没有找到,才会查找默认目录。

现在,我知道我们可以在 FreeMarkerConfigurationFactory setTemplateLoaderPaths(String... templateLoaderPaths) 中传递多个路径。但是这个方法是否保持了查找顺序呢?

英文:

We are using freemarker templates in our spring boot project for email.

There is one default directory in classpath where all base email templates are stored. And, then there are other directories for client's custom email templates.

What we want is that the template loader should first search for a given email template in the client's custom directory, and if not found, then only look into default directory.

Now, I know we can pass multiple paths in FreeMarkerConfigurationFactory setTemplateLoaderPaths(String... templateLoaderPaths). But does this method maintain the lookup order?

答案1

得分: 0

FreeMarkerConfigurationFactory 使用这些路径创建一个 MultiTemplateLoader,其中说明:

> 一个 TemplateLoader,它使用一组其他加载器来加载模板。在每个请求上,加载器按照它们在构造函数中提供的加载器数组中的出现顺序进行查询。

因此,是的,该方法维护了查找顺序。

英文:

FreeMarkerConfigurationFactory uses the paths to create a MultiTemplateLoader, which says:

> A TemplateLoader that uses a set of other loaders to load the templates. On every request, loaders are queried in the order of their appearance in the array of loaders provided to the constructor.

So yes, the method maintains the lookup order.

huangapple
  • 本文由 发表于 2020年10月12日 23:05:10
  • 转载请务必保留本文链接:https://go.coder-hub.com/64320376.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定