public static String processTemplate(String tpl, Map<String, ?> params){
        Iterator<String> it = params.keySet().iterator();
        while(it.hasNext()){
            String k = it.next();
            Object v = params.get(k);
            String val = v == null ? "" : v.toString();
            tpl = tpl.replace("${"+k+"}", val);
        }
        return tpl;
    }

 使用事例:

tpl:
	${confirmOrganName} ${confirmDepartName} ${confirmDoctorName} ${orderText}${sourceLevelText}门诊。${mydate}
params:
	Map<String, Object> params= new HashMap<String, Object>();
	params.put("confirmOrganName", organName);
	params.put("confirmDepartName", departName);
	params.put("confirmDoctorName", doctorName);
	params.put("orderText", confirmClinicTime);
	params.put("sourceLevelText", sourceLevelTextName);
	params.put("mydate", mydate);

  

 

posted on 2017-04-13 11:11  houxiurong.com  阅读(204)  评论(0编辑  收藏  举报
< a href="http://houxiurong.com">houxiurong.com