简体   繁体   中英

A clean technique or library to generating emails in Java

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM