public Map<Integer,List<MeetMenu>> getRoleMenu(int userId) {
Map<Integer,List<MeetMenu>> mapMenu = new HashMap<Integer,
List<MeetMenu>>();
// 拼凑权限条件
List<RoleMenu> list = userDao.getRoleMenuIds(userId);
List<MeetMenu> menuList = null;
if(list.size()>0){
StringBuffer sb = new StringBuffer();
for(RoleMenu rm:list){
sb.append(rm.getMenuId());
sb.append(",");
}
String menuIds =
sb.toString().substring(0,sb.toString().length()-1);
menuList = userDao.getMenuList(menuIds);
for(MeetMenu mm:menuList){
if(mm.getParentId()==0){
int menuId = mm.getMenuId();
List<MeetMenu> listOneList = userDao.getMenuOneList(menuIds,
menuId);
mapMenu.put(menuId,listOneList);
}
}
System.out.println("-------------------------------------------");
System.out.println("mapMenu size = "+mapMenu.size());
Iterator it = mapMenu.entrySet().iterator();
while (it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
int menuId = Integer.parseInt(entry.getKey().toString());
System.out.println("menuId = "+ menuId);
List<MeetMenu> mlist = (List<MeetMenu>)entry.getValue();
for(MeetMenu m:mlist){
System.out.println(m.getMenuName()+" "+m.getLinkUrl());
}
}
System.out.println("-------------------------------------------");
}
return mapMenu;
}
=====================================================================解析
<c:forEach items="${menuList}" var="ml" varStatus="states">
<c:out value="${ml.key}"></c:out> ->
<c:forEach items="${ml.value}" var="menu" varStatus="menuStates">
<c:out value="${menu.menuName}"></c:out>
</c:forEach>
</c:forEach>
java和JSTL遍历map
最新推荐文章于 2022-02-27 12:20:27 发布