在Spring中使用电子邮件模板

时间:2010-02-15 09:36:26

标签: spring

我正在使用Spring开发一个小型实用程序应用程序emailafriend。基本功能是将当前网址通过电子邮件发送给朋友。截至目前,我正在使用固定的电子邮件模板,我在课堂上硬编码了 -

StringBuffer buf = new StringBuffer(form.getSenderName());
buf.append(" want to look at this page: ").append("\n\n<");
buf.append("http://").append(host).append(form.getPageUrl()).append(">\n\n");
buf.append("Please click on the link above for more information.");
buf.append("\n\n");

但是,可以根据业务频繁更改电子邮件模板。我可以为此目的(或任何其他方式)使用spring,以便我不必一次又一次地使用Java代码。

1 个答案:

答案 0 :(得分:1)

我建议使用Freemarker这样的模板引擎(或Velocity,但Freemarker更好,IMO)。春天provides support为这些。