jodd邮件组件是否支持模板引擎?
Does jodd email component support templates engine?
Jodd 框架http://jodd.org/doc/email.html 提供了一个用于发送电子邮件的库。它是否支持某些模板引擎?
它不直接。 Jodd email 只是发送电子邮件。但是您可以非常轻松地使用任何模板引擎(Freemarker、Velocity...)来构建消息正文。流程将是这样的(伪代码):
Map context = ... // this is your context map; filled with variable values
String message = parse(template, context); // every engine has some way to apply context to the template
Email.create()
.from("...@jodd.org")
.to("...@jodd.org")
.subject("Hello!")
.addHtml(message);
您甚至可以使用 Jodds simple String Template Parser - 非常简单的模板解析器,可以替换上下文映射的值。
Jodd 框架http://jodd.org/doc/email.html 提供了一个用于发送电子邮件的库。它是否支持某些模板引擎?
它不直接。 Jodd email 只是发送电子邮件。但是您可以非常轻松地使用任何模板引擎(Freemarker、Velocity...)来构建消息正文。流程将是这样的(伪代码):
Map context = ... // this is your context map; filled with variable values
String message = parse(template, context); // every engine has some way to apply context to the template
Email.create()
.from("...@jodd.org")
.to("...@jodd.org")
.subject("Hello!")
.addHtml(message);
您甚至可以使用 Jodds simple String Template Parser - 非常简单的模板解析器,可以替换上下文映射的值。