模板文件
<p>
<h4>approval</h4>
<br/>
<p>this is a test context data.{0}</p>
</p>
读取模板文件代码
private static final String templatePath="template/";
private static final String templateSuffix=".xml";
public static String getTemplateContent(String templateName,Object... params){
try{
String resourcePath = templatePath+templateName+templateSuffix;
logger.info("resource path":+resourcePath);
File file = Resources.getResourceAsFile(resourcePath);
if(!file.exists()){
logger.info("file not exists:"+file.exists());
return null;
}
String templateContent = FileUtils.readFileToString(file,"UTF-8");
return MessageFormat.format(templateContent,params);
}catch(IOException e){
logger.error("IOException",e);
}
return null;
}