使用bee生成xml文件

来源:互联网 发布:交友网站 知乎 编辑:程序博客网 时间:2024/06/04 19:26
                               Template tmp = BeeTemplateHelper
.getTemplateByFile("");//模板路径 
tmp.binding("deductXmlList", collection); // 绑定模板显示数据

result = tmp.render();






public static Template getTemplateByFile(String file) {
ClasspathResourceLoader resourceLoader = new ClasspathResourceLoader();
Configuration cfg;
try {
cfg = Configuration.defaultConfiguration();
} catch (IOException e) {
logger.error(e.getMessage());
return null;
}
GroupTemplate classPathGt = new GroupTemplate(resourceLoader, cfg);
return classPathGt.getTemplate(file);
}



--模版

<?xml version="1.0" encoding="UTF-8"?>
<data>
<header>
<th>
<hd></hd>
<hd></hd>
<hd></hd>
<hd></hd>
<hd></hd>
<hd></hd>
<hd></hd>
</th>
</header>
<body>
<% for(deductXml in deductXmlList){ %>
<rd>
<td>${deductXml.payableTm,dateFormat="yyyy-MM-dd"}</td>
<td>${deductXml.waybillNo}</td>
<td>
${deductXml.strFeeDetails}
</td>
<td>
${deductXml.strDeductDetails}
</td>
<td>${deductXml.strPayableAmt}</td>
<td>${deductXml.senderCustomerName}</td>
<td>${deductXml.receiverCustomerName}</td>
</rd>
<%}%>
</body>
</data>

0 0
原创粉丝点击