91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

資源簡介

java實現的根據html模版內容發送郵件,這是一個完整的eclipse項目,包含jar包,導入即可運行

資源截圖

代碼片段和文件信息

package?com.test;

import?java.io.File;
import?java.io.FileWriter;
import?java.io.IOException;
import?java.io.PrintWriter;
import?java.util.Map;
import?freemarker.template.Configuration;
import?freemarker.template.Template;
import?freemarker.template.TemplateException;

public?class?FreemarkerUtil?{
/**
?*?獲取模板
?*?
?*?@param?name
?*?@return
?*/
public?static?Template?getTemplate(String?name)?{
try?{
//?通過Freemaker的Configuration讀取相應的ftl
Configuration?cfg?=?new?Configuration();
//?設定去哪里讀取相應的ftl模板文件
cfg.setClassForTemplateLoading(FreemarkerUtil.class?“/mail“);
//?在模板文件目錄中找到名稱為name的文件
Template?temp?=?cfg.getTemplate(name);
return?temp;
}?catch?(IOException?e)?{
e.printStackTrace();
}
return?null;
}

/**
?*?輸出到控制臺
?*?
?*?@param?name
?*????????????模板文件名
?*?@param?root
?*/
public?void?print(String?name?Mapject>?root)?{
try?{
//?通過Template可以將模板文件輸出到相應的流
Template?temp?=?this.getTemplate(name);
temp.process(root?new?PrintWriter(System.out));
}?catch?(TemplateException?e)?{
e.printStackTrace();
}?catch?(IOException?e)?{
e.printStackTrace();
}
}

/**
?*?輸出到文件
?*?
?*?@param?name
?*?@param?root
?*?@param?outFile
?*/
public?void?fprint(String?name?Mapject>?root?String?outFile)?{
FileWriter?out?=?null;
try?{
//?通過一個文件輸出流,就可以寫到相應的文件中
out?=?new?FileWriter(new?File(“E:\\freemarker\\ftl\\“?+?outFile));
Template?temp?=?this.getTemplate(name);
temp.process(root?out);
}?catch?(IOException?e)?{
e.printStackTrace();
}?catch?(TemplateException?e)?{
e.printStackTrace();
}?finally?{
try?{
if?(out?!=?null)
out.close();
}?catch?(IOException?e)?{
e.printStackTrace();
}
}
}
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????目錄???????????0??2014-01-22?14:34??mailTest\
?????文件?????????634??2014-01-22?14:34??mailTest\.classpath
?????文件?????????384??2014-01-22?14:34??mailTest\.project
?????目錄???????????0??2014-01-22?14:34??mailTest\.settings\
?????文件??????????57??2014-01-22?14:34??mailTest\.settings\org.eclipse.core.resources.prefs
?????文件?????????598??2014-01-22?14:34??mailTest\.settings\org.eclipse.jdt.core.prefs
?????目錄???????????0??2014-01-22?14:34??mailTest\bin\
?????目錄???????????0??2014-01-22?14:34??mailTest\bin\com\
?????目錄???????????0??2014-01-22?14:34??mailTest\bin\com\test\
?????文件????????2826??2014-01-22?14:34??mailTest\bin\com\test\FreemarkerUtil.class
?????文件????????8474??2014-01-22?14:34??mailTest\bin\com\test\MailSender.class
?????文件????????4807??2014-01-22?14:34??mailTest\bin\com\test\MailUtil.class
?????目錄???????????0??2014-01-22?14:34??mailTest\bin\mail\
?????文件?????????286??2014-01-22?14:34??mailTest\bin\mail\mail.properties
?????文件??????????19??2014-01-22?14:34??mailTest\bin\mail\mailTemplate.ftl
?????目錄???????????0??2014-01-22?14:34??mailTest\lib\
?????文件??????879259??2014-01-22?14:34??mailTest\lib\freemarker-2.3.15.jar
?????文件??????489884??2014-01-22?14:34??mailTest\lib\log4j-1.2.17.jar
?????文件??????344968??2014-01-22?14:34??mailTest\lib\mailUtil.jar
?????文件??????107014??2014-01-22?14:34??mailTest\lib\spring-context-support-3.1.2.RELEASE.jar
?????文件??????449649??2014-01-22?14:34??mailTest\lib\spring-core-3.1.2.RELEASE.jar
?????目錄???????????0??2014-01-22?14:34??mailTest\src\
?????目錄???????????0??2014-01-22?14:34??mailTest\src\com\
?????目錄???????????0??2014-01-22?14:34??mailTest\src\com\test\
?????文件????????2002??2014-01-22?14:34??mailTest\src\com\test\FreemarkerUtil.java
?????文件????????7154??2014-01-22?14:34??mailTest\src\com\test\MailSender.java
?????文件????????5979??2014-01-22?14:34??mailTest\src\com\test\MailUtil.java
?????目錄???????????0??2014-01-22?14:34??mailTest\src\mail\
?????文件?????????286??2014-01-22?14:34??mailTest\src\mail\mail.properties
?????文件??????????19??2014-01-22?14:34??mailTest\src\mail\mailTemplate.ftl

評論

共有 條評論