1.数据结构
复制代码
2.前端页面循环
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35List<Map<String,Object>> mapList = Lists.newArrayList(); Long originalOrderId = returnObj.getOriginalOrderId(); List<Long> orderIdList = Lists.newArrayList(); orderIdList.add(originalOrderId); List<Item> itemList = itemService.listByOrderIdList(orderIdList); for (Item item : itemList) { Map<String,Object> map = Maps.newLinkedHashMap(); if(item != null){ Product product = item.getProduct(); if(product == null){ product = productService.get(item.getProductId()); } if(product != null){ map.put("productName", product.getName()); } List<SpecJsonItem> specList = item.getSpecItemList(); if(CollectionUtils.isEmpty(specList)){ specList = JSON.parseArray(item.getSpecJson(), SpecJsonItem.class); } if(CollectionUtils.isNotEmpty(specList)){ StringBuffer spec = new StringBuffer(); for (SpecJsonItem specJsonItem : specList) { spec.append(specJsonItem.getName()).append(":").append(specJsonItem.getValue()).append(" "); } map.put("spec", spec); } }else{ item = new Item(); } map.put("item", item); mapList.add(map); } model.addAttribute("mapList", mapList);
复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20<#list mapList as map> <tr class="product_${map_index}"> <td>商品名称:</td> <td>${map['productName']}</td> <td rowspan="2">商品图片:</td> <td rowspan="2"><img src="${imageDomain}/${map['item'].pic}@200w"></td> </tr> <tr class="product_${map_index}"> <td>购买规格:</td> <td>${map['spec']}</td> </tr> <tr class="product_${map_index}"> <td>购买价格:</td> <td>${map['item'].price}</td> <td>购买数量:</td> <td>${map['item'].quantity}</td> </tr> </#list>
最后
以上就是懦弱日记本最近收集整理的关于freemarker循环获取list中map的值的全部内容,更多相关freemarker循环获取list中map内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复