Iterator<Entry<Object, List<Map<String, Object>>>> itera = map.entrySet().iterator(); while(itera.hasNext()){ Map.Entry<Object, List<Map<String, Object>>> entry = (Map.Entry<Object, List<Map<String, Object>>>)itera.next(); if(entry.getValue().size() == 0){ flag = true; } } if(flag){ List<Map<String, Object>> mapt = groupService.getProductTreeByIdzs(id); mav.addObject("mapt", mapt); }