关于freemarker中循环list中的map问题
来源:互联网 发布:福禄网络 编辑:程序博客网 时间:2024/05/22 13:53
1.从List集合取一个Map集
例如:
Java代码:List list = new ArrayList();
Map map1 = new HashMap();map1.put("phone", "13655555555");map1.put("email", "admin@vip.com");list.add(map1);Map map2 = new HashMap();map2.put("phone", "13888888888");map2.put("email", "china@vip.com");map2.put("address", "beijing");list.add(map2);test.ftl文件:<#list list as map><#list map?keys as itemKey> <#if itemKey="phone"> Phone:${map[itemKey]} </#if> <#if itemKey="email"> Email:${map[itemKey]} </#if></#list></#list>
2. 复杂的list集合里面map,map里面套有list2集合,list2里面还有map
java代码:
- List<Map<String,Object>> typeList=new ArrayList<Map<String,Object>>();
- for(MerchantSettledTypeInfo merchantSettledType:merchantSettledTypeSet){
- Map<String,Object> typeMap=new HashMap<String,Object>();
- ProductTypeInfo type=merchantSettledType.getProductType();
- typeMap.put("id", type.getId());
- typeMap.put("name", type.getName());
- //商品分类list,里面若干个分类map
- List<Map<String,String>> categoryList=new ArrayList<Map<String,String>>();
- List<ProductCategoryInfo> categoryList =merchantSettledType.getProductCategoryListId());
- for( ProductCategoryInfo cate: categoryList){
- Map<String,String> categoryMap=new HashMap<String,String>();
- categoryMap.put("id", cate.getId().toString());
- categoryMap.put("name", cate.getName());
- categoryList.add(categoryMap);
- }
- typeMap.put("categoryList", categoryList);
- typeList.add(typeMap);
- 前台ftl 页面代码:
- <#list productTypeCateList as middleMap> <#list middleMap?keys as itemKey> <tr> <#if itemKey=="name"> <td>${(middleMap[itemKey])!}</td> </#if> <#if itemKey=="categoryList"> <#list middleMap[itemKey] as cateMap> <#list cateMap?keys as cateKey> <#if itemKey=="name"> <td>${(cateMap[cateKey])!}</td> </#if> </#list> </#list> </#if> </tr> </#list> </#list>
0 0
- 关于freemarker中循环list中的map问题
- freemarker循环获取list中map的值
- freemarker循环Map<String,List<User>>对象
- freemarker中的map和list遍历
- freemarker中遍历list<map<String,String>>
- freemarker中遍历list<map<String,String>>
- freemarker map 中 嵌套list的例子
- freemarker 中list循环 时间处理
- freemarker中map的创建以及map的遍历循环
- freemarker中map的创建以及map的遍历循环
- freemarker中map的创建以及map的遍历循环
- freemarker循环遍历Map
- freemarker 循环map
- 关于freemarker map遍历的问题
- freemarker list map 实例
- 关于jstl中foreach遍历list中map的问题
- Freemarker循环list
- 关于freeMarker得到list长度的问题
- Spring AOP 详解
- Android JVM 学习
- 【SIP协议实践】之注册流程
- eclipse/myeclipse注释模板的修改
- Sed
- 关于freemarker中循环list中的map问题
- git的小点
- sed命令详解
- 关于http服务器和selinux权限设置
- SQL2005数据库收缩日志文件
- PHP-redis中文文档介绍
- thinkphp 跨控制器调用
- ACM-矩阵专题
- Objective-C Runtime-深入介绍 Messaging 机制