while(matcher.find()){
String m= template.substring(matcher.start(),matcher.end());
StringWriter sw=new StringWriter();
try {
VelocityContext context=new VelocityContext();
context.put("zdt", new ZeusDateTool());
Velocity.evaluate(context, sw, "", m);
if(m.equals(sw.toString())){
//渲染后和原数据一样,则直接跳出,如果不跳出会导致死循环
log.error("render fail with target:"+m);
break;
}
} catch (Exception e) {
log.error("zdt render error",e);
break;//防止死循环
}
template=template.replace(m, sw.toString());
matcher=pt.matcher(template);
}
//${yesterday}变量替换
template=template.replace("${yesterday}",new ZeusDateTool().addDay(-1).format("yyyyMMdd"));
return template;
}