html中需生成一个表格,但表格行数不确定
html
<#list LIST as lender> <tr> <td>${lender.name!""}</td> <td>${lender.idType!""}</td> <td>${lender.idNum!""}<br> <td>${lender.L1!""}<br> <td>${lender.L2!""}<br> <td>${lender.L3!""}<br> <td>${lender.L4!""}<br> <td>${lender.L5!""}<br> <td>${lender.L6!""}<br> <td>${lender.L7!""}<br> <td>${lender.L8!""}<br> <td>${lender.L9!""}<br> </td> </tr></#list>java代码
List<LenderInfo> list = vo.getLenderList();
List<Map<String, Object>> paramList = new ArrayList<>();
if(list != null && vo.getLenderList().size() > 0) {
for(int i = 1; i <= vo.getLenderList().size(); i++){
Map<String, Object> paramMap = new HashMap<>();
paramMap.put("name", list.get(i - 1).getName());
paramMap.put("idType", list.get(i - 1).getIdType());
paramMap.put("idNum", list.get(i - 1).getIdNum());
BigDecimal lenderAmount = list.get(i - 1).getLenderAmount();
String[] lenderAmountArr = moneyToArr(lenderAmount);
m = 0;
for (int j = 1; j < 10; j++) {
if (lenderAmountArr.length + j == 9) {
paramMap.put("L" + j, "¥");
m = j;
} else if (lenderAmountArr.length + j < 9) {
paramMap.put("L" + j, "");
} else {
paramMap.put("L" + j, lenderAmountArr[j - m - 1]);
}
}
paramList.add(paramMap);
}
}
parameters.put("LIST", paramList);
String t = tm.mergeFile(templateFileName, parameters);