<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <!--框架必需start--> <script type="text/javascript" src="../js/jquery-1.4.js"> </script> <script type="text/javascript" src="../js/framework.js"> </script> <link href="../css/import_basic.css" rel="stylesheet" type="text/css" /> <link rel="stylesheet" type="text/css" id="skin" /> <!--框架必需end--> <script type="text/javascript" src="../js/nav/ddaccordion.js"> </script> <script type="text/javascript" src="../js/text/text-overflow.js"> </script> <style> a { } .categoryitems span { width: 160px; } </style> <script> //打开内页时出现进度条 $(function() { $(".categoryitems a[target*=frmright]").click(function() { showProgressBar(); }) }) function ccc() { doAjax("../Removeabc", null, function(rstText) { var result = eval('(' + rstText + ')'); if (result.status == 'OK') { alert("查询成功"); return true; } else { alert("查询失败"); return false; } }); } function getXMLHttpResquest() { var request; if (window.XMLHttpRequest) { request = new XMLHttpRequest(); } else { try { request = new ActiveXObject("Microsoft.XMLHTTP"); } catch (e) { request = new ActiveXObject("Msxml2.XMLHTTP"); } } return request; } function doAjax(url, params, callBack) { var req = getXMLHttpResquest(); if (req != null) { req.onreadystatechange = function() { if (req.readyState == 4) { if (200 == req.status) { callBack(req.responseText); } else if (404 == req.status) { alert('404-HTTP请求路径错误!'); } else if (500 == req.status) { alert('500-HTTP请求路径错误!'); } } }; req.open("POST", url, true); req.setRequestHeader("Content-Type","application/x-www-form-urlencoded;;charset=utf-8"); req.send(params); } } $(function() { var power; var html = ""; $ .ajax({ url : "../PowerServlet", type : "post", dataType : "json", success : function(data) { $ .each( data, function(i, item) { power = item.power; if (power == 1) { html += "<li><a href='../AllUserServlet' target='frmright'><span class='text_slice'>用户管理</span></a></li>" + "<li><a href='../AllJokerServlet' target='frmright'><span class='text_slice'>角色管理</span></a></li>" + "<li><a href='../AllPowerServlet' target='frmright'><span class='text_slice'>权限管理</span></a></li>" + "<li><a href='../AllTableServlet' target='frmright'><span class='text_slice'>需求管理</span></a></li>" + "<li><a href='../XSSHServlet?method=XSAllTable' target='frmright'><span class='text_slice'>形式审核</span></a></li>" + "<li><a href='../BMSHServlet?method=BSAllTable' target='frmright'><span class='text_slice'>部门审核</span></a></li>" + "<li><a href='../tjcx/tjcx.jsp' target='frmright'><span class='text_slice'>统计查询</span></a></li>" + "<li><a href='../user/xgmm.jsp' target='frmright'><span class='text_slice'>修改密码</span></a></li>" + "<li><a href='../templete/xtjs.html' target='frmright'><span class='text_slice'>系统介绍</span></a></li>" + "<li><a href='../templete/bzwj.html' target='frmright'><span class='text_slice'>帮助文件</span></a></li>" + "<li><a href='../templete/cjwtjd.html' target='frmright'><span class='text_slice'>常见问题解答</span></a></li>"; } else{ if (item.xqzj_qx == 1) { html += "<li><a href='../table/table.jsp' target='frmright'><span class='text_slice'>需求征集</span></a></li>"; } if (item.xqgl_qx == 1) { html += "<li><a href='../AllTableServlet' target='frmright'><span class='text_slice'>需求管理</span></a></li>"; } if (item.yhxx_qx == 1) { html += "<li><a href='../MyMessageServlet?method=getMyMessageById' target='frmright'><span class='text_slice'>用户信息</span></a></li>"; } if (item.xgmm_qx == 1) { html += "<li><a href='../user/xgmm.jsp' target='frmright'><span class='text_slice'>修改密码</span></a></li>"; } if (item.xssh_qx == 1) { html += "<li><a href='../XSSHServlet?method=XSMyTable' target='frmright'><span class='text_slice'>形式审核</span></a></li>"; } if (item.bmsh_qx == 1) { html += "<li><a href='../BMSHServlet?method=BSMyTable' target='frmright'><span class='text_slice'>部门审核</span></a></li>"; } if (item.tjxq_qx == 1) { html += "<li><a href='../tjcx/tjcx.jsp' target='frmright'><span class='text_slice'>统计查询</span></a></li>"; } html += "<li><a href='../templete/xtjs.html' target='frmright'><span class='text_slice'>系统介绍</span></a></li>"; html += "<li><a href='../templete/bzwj.html' target='frmright'><span class='text_slice'>帮助文件</span></a></li>"; html += "<li><a href='../templete/cjwtjd.html' target='frmright'><span class='text_slice'>常见问题解答</span></a></li>"; } $("#category").html(html); }); } }); }) </script> <body leftFrame="true"> <div id="scrollContent"> <div class="arrowlistmenu"> <div class="menuheader expandable">系统菜单</div> <ul class="categoryitems" id="category"></ul> </body> </html>
用了动态HTML实现不同角色的登录以及不同角色的权限管理(即管理员可分配每个角色左侧导航栏的超链接)
核心代码:
$(function() { var power; var html = ""; $ .ajax({ url : "../PowerServlet", type : "post", dataType : "json", success : function(data) { $ .each( data, function(i, item) { power = item.power; if (power == 1) { html += "<li><a href='../AllUserServlet' target='frmright'><span class='text_slice'>用户管理</span></a></li>" + "<li><a href='../AllJokerServlet' target='frmright'><span class='text_slice'>角色管理</span></a></li>" + "<li><a href='../AllPowerServlet' target='frmright'><span class='text_slice'>权限管理</span></a></li>" + "<li><a href='../AllTableServlet' target='frmright'><span class='text_slice'>需求管理</span></a></li>" + "<li><a href='../XSSHServlet?method=XSAllTable' target='frmright'><span class='text_slice'>形式审核</span></a></li>" + "<li><a href='../BMSHServlet?method=BSAllTable' target='frmright'><span class='text_slice'>部门审核</span></a></li>" + "<li><a href='../tjcx/tjcx.jsp' target='frmright'><span class='text_slice'>统计查询</span></a></li>" + "<li><a href='../user/xgmm.jsp' target='frmright'><span class='text_slice'>修改密码</span></a></li>" + "<li><a href='../templete/xtjs.html' target='frmright'><span class='text_slice'>系统介绍</span></a></li>" + "<li><a href='../templete/bzwj.html' target='frmright'><span class='text_slice'>帮助文件</span></a></li>" + "<li><a href='../templete/cjwtjd.html' target='frmright'><span class='text_slice'>常见问题解答</span></a></li>"; } else{ if (item.xqzj_qx == 1) { html += "<li><a href='../table/table.jsp' target='frmright'><span class='text_slice'>需求征集</span></a></li>"; } if (item.xqgl_qx == 1) { html += "<li><a href='../AllTableServlet' target='frmright'><span class='text_slice'>需求管理</span></a></li>"; } if (item.yhxx_qx == 1) { html += "<li><a href='../MyMessageServlet?method=getMyMessageById' target='frmright'><span class='text_slice'>用户信息</span></a></li>"; } if (item.xgmm_qx == 1) { html += "<li><a href='../user/xgmm.jsp' target='frmright'><span class='text_slice'>修改密码</span></a></li>"; } if (item.xssh_qx == 1) { html += "<li><a href='../XSSHServlet?method=XSMyTable' target='frmright'><span class='text_slice'>形式审核</span></a></li>"; } if (item.bmsh_qx == 1) { html += "<li><a href='../BMSHServlet?method=BSMyTable' target='frmright'><span class='text_slice'>部门审核</span></a></li>"; } if (item.tjxq_qx == 1) { html += "<li><a href='../tjcx/tjcx.jsp' target='frmright'><span class='text_slice'>统计查询</span></a></li>"; } html += "<li><a href='../templete/xtjs.html' target='frmright'><span class='text_slice'>系统介绍</span></a></li>"; html += "<li><a href='../templete/bzwj.html' target='frmright'><span class='text_slice'>帮助文件</span></a></li>"; html += "<li><a href='../templete/cjwtjd.html' target='frmright'><span class='text_slice'>常见问题解答</span></a></li>"; } $("#category").html(html); }); } }); })
power等于1时是管理员,拥有所有的权限;power等于0时是其他用户,根据每个角色的权限不相同,左侧导航栏的标签也不同。