c标签遍历map , 另外从后端传过来的map来替换原表中的颜色id字段,这是与c标签的结合
<c:if test="${flag==2 }">
<c:forEach items="${resultMap }" var="map" varStatus="status">
<br>
<br>
<div style="float: left;">
<span style="font-size: 14px;">${map.key }</span>
</div>
<table width="100%" cellspacing="0" class="table-c" style="border-right:1px solid #444444;border-bottom:1px solid #444444;">
<tr>
<td width="54%" height="100%"><div style="height:100%">
<table border="0" height="100%" width="100%" cellspacing="2" style="background-color:#FFFFFF;">
<tr>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">序号</td>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">用料</td>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">资材说明</td>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">使用部位</td>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">数量</td>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">颜色</td>
</tr>
<c:forEach items="${map.value }" var="t" varStatus="status">
<tr>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">${status.index+1}</td>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">${t._cmaterial.name }</td>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">${t.description }</td>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">${t.position }</td>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">${t.qty }</td>
<td style="font-size:12px;border-left:1px solid #444444;border-top:1px solid #444444;">${colorMap[t._cmaterial.colorId]}</td>
</tr>
</c:forEach>
</table>
</div></td>
</tr>
</table>
</c:forEach>
</c:if>
后台
List resultList = new ArrayList();
if(list.size()==list2.size()){//bom 一层结构
request.setAttribute("resultList", list2);
request.setAttribute("flag", "1");
}else{//bom 二层结构
request.setAttribute("flag", "2");
Map<String,List<BiMtlBom>> map = new HashMap();
for (BiMtlBom bb : list) {
//Material
Integer cid = bb.getCmaterial().getId();
sql = "from BiMtlBom where pMtlId = "+ cid + " and orderDetailId = '" + orderDetailId+"'";
List bbList = publicService.executeObjectSql(sql);
map.put(bb.getCmaterial().getName(), bbList);
}
request.setAttribute("resultMap", map);
}
List<BiMtlColor> colorList = publicService.executeObjectSql("from BiMtlColor");
Map colorMap = new HashMap();
for (BiMtlColor bmc : colorList) {
colorMap.put(bmc.getId(), bmc.getName());
}
request.setAttribute("colorMap", colorMap);
return super.edit(form, parameterMap);