//权限处理start//
Integer rolenum4 = bruser.getRolenum();//1、从session中获取当前登陆的角色编号
List<BrRoleconnectmenu> rlist=brRoleconnectmenuDAO.findByRolenum(rolenum4);//2根据当前登录的角色编号查询 角色菜单关联表
List<BrMenu>
listall =new ArrayList<BrMenu>();
for (BrRoleconnectmenu brRoleconnectmenu : rlist) {
Integer in = brRoleconnectmenu.getMenunum();
//System.out.println(in);
List<BrMenu> mlist = brMenuDAO.findByMenuNum(in);//3根据菜单编号 查询 菜单表
for (int i=0;i<mlist.size();i++) {
BrMenu brMenu = mlist.get(i);
listall.add(brMenu);
}
}
List<FMenu>
fflist = new ArrayList<FMenu>();
for (int i=0;i<
listall.size();i++) { //4循环遍历查询得到的菜单表
BrMenu brMenu = listall.get(i);
if (brMenu.getSupermenunum() == 0) {
FMenu fMenu = new FMenu();
fMenu.setMenunum(brMenu.getMenunum());
fflist.add(fMenu);
}
}
for (FMenu fMenu :
fflist) {
List<BrMenu>
bmlist = new ArrayList<BrMenu>();
for (BrMenu brMenu :
listall) {
if(brMenu.getMenunum()!=0 && brMenu.getSupermenunum().equals(fMenu.getMenunum())){//如果
上级菜单编号等于
菜单编号
bmlist.add(brMenu);
}
}
fMenu.setMnlist(
bmlist);
}
session.setAttribute("flist", fflist);//一级菜单
session.setAttribute("menuCDlist", brMenuDAO.getAll());
//权限处理end//
jsp:
List<BrMenu> menulist = (List)session.getAttribute("menuCDlist");//1级菜单
List<FMenu> flist = (List)session.getAttribute("flist");//2级菜单
<!-- ---循环模块------>
<ul id="demo-list">
<%
for(int i=0;i<flist.size();i++){
int flag = 0;
FMenu fMenu = flist.get(i);
for(int j=0;j<menulist.size();j++){
if(menulist.get(j).getMenunum().equals(fMenu.getMenunum())){//
flag = j;
}
}
%>
<li class="active"><a href="javascript:void(0);"><%=menulist.get(flag).getMenuname() %></a>
<ul class="submenu">
<%List<BrMenu> mnlist =(List<BrMenu>) fMenu.getMnlist();
for(int k=0;k<mnlist.size();k++){
%>
<li><a href="javascript:void(0);" id="<%=mnlist.get(k).getMenucode()%>"><%=mnlist.get(k).getMenuname() %></a></li>
<% }%>
</ul>
</li>
<%} %>
</ul>