String grandSonId=null;
String menuId = "c4389e26-d157-4886-b310-1c0a7142719c";
List<MenuResponse> childMenu = new ArrayList<MenuResponse>();
List menuList = (ArrayList) session.getAttribute(PdtzjcConst.SESSION_MENU_LIST);
boolean bcFlag= false;
if (menuList != null && menuList.size() > 0) {
for (int k = 0; k < menuList.size(); k++) {
MenuResponse menuRes = (MenuResponse) menuList.get(k);
if (menuId.equals(menuRes.getId())) {
childMenu = menuRes.getChildren();
System.out.print(childMenu);
if (childMenu!=null&&childMenu.size()>0) {
for (int i = 0; i < childMenu.size(); i++) {
if ("专报审核".equals(childMenu.get(i).getName())) {
List<MenuResponse> childrenMenus = childMenu.get(i).getChildren();
if (childrenMenus!=null&&childrenMenus.size()>0) {
for (int j = 0; j < childrenMenus.size(); j++) {
grandSonId= childrenMenus.get(j).getId();
if(grandSonId.equals("8a81ab875af9b8c9015af9ce78230010")||grandSonId.equals("8a81ab87506f41210150897018650024")){
System.out.print(grandSonId+"------");
bcFlag = true;
}else{
//System.out.print(grandSonId);
}
}
}
}
}
}
}
}
}
......................
$(function() {
var bc='<%=bcFlag%>'
if(bc=="true"){
$("#jlrysh").css('display','block') ;//显示
$("#ybsh").css('display','block') ;
}else{
$("#jlrysh").css('display','none'); //隐藏
$("#ybsh").css('display','none');
}
});
------------------------------------------------
首先对两个人(a与b)的权限进行勾选,若a有权限那么grandsonid就能循环到,b没权限就循环不到
那么由于对grandsonid定义的是string那么想了两个方案
1.用indexof(),最后grandsonid会变成一个长的拼接起来的字符串那么把要用的id找出来匹配
2.用的如果存在相等的就赋值为true如果没有就是false然后做操作