速度模板 - 消息键 #msg

Velocity template - message key #msg

提问人:yosr ben daly 提问时间:9/20/2023 更新时间:9/20/2023 访问量:21

问:

我有电子邮件模板 .vm,其中包含带有来自 messages_en.properties 的消息密钥的 msg:

#msg("email-ePwdReminder-salutation")

并创建了 Velocity 上下文,如下所示:

VelocityContext context = new VelocityContext();
context.put("email-ePwdReminder-salutation",messageSource.getMessage("email.ePwdReminder.salutation",null,locale));
Merge the template with the context to generate the HTML body
StringWriter writer = new StringWriter();

Replace with logic to fetch the correct template
Template template = velocityEngine.getTemplate(templateName);
template.process();
template.merge(context, writer);

String htmlBody = writer.toString();

#msg 似乎不是速度引擎的预定义指令,那么我该如何创建自定义指令 #msg 并能够替换电子邮件模板中的 email.ePwdReminder.salutation 变量。

Java spring-boot 速度

评论


答: 暂无答案