velocity应用

public void buildIndex(String templateFileName,Map listTemplate,String buildFloder,String basePath) throws Exception{
  VelocityEngine ve=new VelocityEngine();
  ve.init(p);
  org.apache.velocity.Template t = ve.getTemplate(templateFileName);
  VelocityContext context = new VelocityContext();
     Iterator  iter=listTemplate.keySet().iterator();
     while(iter.hasNext()){
        Object key=iter.next();
       
        if("gwdtIndex".equals(key)){
         List gwdtIndex = (List)listTemplate.get("gwdtIndex");
              context.put("gwdtIndex", gwdtIndex);
        }
        if("dlhyxxIndex".equals(key)){
         List dlhyxxIndex = (List)listTemplate.get("dlhyxxIndex");
              context.put("dlhyxxIndex", dlhyxxIndex);
        }
        if("dlssbhIndex".equals(key)){
         List dlssbhIndex = (List)listTemplate.get("dlssbhIndex");
              context.put("dlssbhIndex", dlssbhIndex);
        }
        if("shzrIndex".equals(key)){
         List shzrIndex = (List)listTemplate.get("shzrIndex");
              context.put("shzrIndex", shzrIndex);
        
        }
        if("yzfwIndex".equals(key)){
         List yzfwIndex = (List)listTemplate.get("yzfwIndex");
              context.put("yzfwIndex", yzfwIndex);
        
        }
        if("dwjsIndex".equals(key)){
         List dwjsIndex = (List)listTemplate.get("dwjsIndex");
              context.put("dwjsIndex", dwjsIndex);
        
        }
        if("sxndIndex".equals(key)){
         List sxndIndex = (List)listTemplate.get("sxndIndex");
              context.put("sxndIndex", sxndIndex);
        
        }
        if("qywhIndex".equals(key)){
         List qywhIndex = (List)listTemplate.get("qywhIndex");
              context.put("qywhIndex", qywhIndex);
        
        }
        if("dlrwIndex".equals(key)){
         List dlrwIndex = (List)listTemplate.get("dlrwIndex");
              context.put("dlrwIndex", dlrwIndex);
        }
       
        if("gsxwIndex".equals(key)){
         List gsxwIndex = (List)listTemplate.get("gsxwIndex");
              context.put("gsxwIndex", gsxwIndex);
        }
       

     } 
  FileOperate fo = new FileOperate();
  StringWriter writer = new StringWriter();
  t.merge(context, writer);
  fo.newFile(sitePath+GOAL_HTML_PATH+"\\"+buildFloder+"\\"+"index.html",writer.toString());
 }

你可能感兴趣的:(apache,html,velocity)