开发者

A clean technique or library to generating emails in Java

开发者 https://www.devze.com 2023-03-11 17:06 出处:网络
Currently our 开发者_运维知识库application generates emails for clients via classic \"string smashing\" mixed in with some String.replace calls.

Currently our 开发者_运维知识库application generates emails for clients via classic "string smashing" mixed in with some String.replace calls.

Does somebody have a suggestion for an easy/elegant/robust way to generate emails? We are not asking for the fanciest stuff in the world. Our application uses GWT/Guice so we do not have any jsps/struts pages.


You can do this with Velocity or Freemarker. There is an example for doing this using Spring and Velocity. Although I haven't tried this on Guice, I would assume that the example would carry over, for Spring performs the injection of the velocity engine.


java.util.MessageFormat.

Alternatively, and much more powerfully, keep your template as XML with tags for the parameters you want to substitute; use XSLT to do the substitution, and XPath to extract just the text from the XML document after processing.

0

精彩评论

暂无评论...
验证码 换一张
取 消