Zeus-参数体系

Zeus使用org.apache.velocity 来处理参数的动态替换。


public static String render(String template){
   if(template==null){
      return null;
   }
   Matcher matcher=pt.matcher(template);
   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;
}

但是Zeus支持的参数表达式很少;

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容