list map List<Map<>> 遍历 20
Map<String,Object>map=newHashMap<String,Object>();map.put("name","张三");map.put("age",...
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", "张三");
map.put("age", 2);
map.put("sex", "男");
List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
listMap.add(map);
Map<String,Object> resultJson = new HashMap<String,Object>();
resultJson.put("listMap", listMap);
问题:
resultJson 能在后台遍历出来了或者取一个值 展开
map.put("name", "张三");
map.put("age", 2);
map.put("sex", "男");
List<Map<String, Object>> listMap = new ArrayList<Map<String, Object>>();
listMap.add(map);
Map<String,Object> resultJson = new HashMap<String,Object>();
resultJson.put("listMap", listMap);
问题:
resultJson 能在后台遍历出来了或者取一个值 展开
1个回答
展开全部
遍历单纯的list数据,例如:List<People> peoples;#{list peoples,as:'people'} //peoples为list对象,people为实体变量名 ,name则为实体相对应的属性值 ${people.name} #{/list}遍历list中泛化的map类型,例如:List<Map<People>> peoples; #{list peoples,as:'people'} //peoples为list对象,people为实体变量名 ,name则为实体相对应的属性值 #{list people,as:'map'}${map.value.property}#{/list} //第二个list将people再次转换,map取值则像正常的取值,value为map的value,可是对象类型,property则为对象类型的属性值 #{/list} 遍历单纯的Map类型,例如:Map<id,People> people;//如果知道map的key值,则可以直接通过一下方式获取: ${people.get(key).name} //如果是要遍历一个map,同样适用list标签 #{list people,as:'peo'} ${peo.value.name} //peo为map变量,value为key的值,name为属性值 #{/list}#{list people.get(id),as:'peo'}${peo.name}#{list}//如果people是多个map对象,则可以#{list people,as: 'map'}#{list map.value,as:'people'set,if,break标签的使用://模拟遍历list时的计数器#{set count:0}//设置变量count#{list data,as:'li'}<h1>${count}</h1>
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询