1、listUI.jsp
在湞江等地區(qū),都構(gòu)建了全面的區(qū)域性戰(zhàn)略布局,加強(qiáng)發(fā)展的系統(tǒng)性、市場前瞻性、產(chǎn)品創(chuàng)新能力,以專注、極致的服務(wù)理念,為客戶提供成都網(wǎng)站建設(shè)、成都做網(wǎng)站 網(wǎng)站設(shè)計(jì)制作按需策劃設(shè)計(jì),公司網(wǎng)站建設(shè),企業(yè)網(wǎng)站建設(shè),品牌網(wǎng)站制作,成都營銷網(wǎng)站建設(shè),外貿(mào)網(wǎng)站制作,湞江網(wǎng)站建設(shè)費(fèi)用合理。
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <%@taglib uri="/struts-tags" prefix="s" %> <html> <head> <%@include file="/common/header.jsp"%> <title>角色管理</title> <script type="text/javascript"> //全選、全反選 function doSelectAll(){ // jquery 1.6 前 //$("input[name=selectedRow]").attr("checked", $("#selAll").is(":checked")); //prop jquery 1.6+建議使用 $("input[name=selectedRow]").prop("checked", $("#selAll").is(":checked")); } //新增角色 function doAdd(){ document.forms[0].action = "${basePath}/tax/role_addUI.action"; document.forms[0].submit(); } //編輯角色 function doEdit(id){ document.forms[0].action = "${basePath}/tax/role_editUI.action?role.roleId="+id; document.forms[0].submit(); } //刪除角色 function doDelete(id){ document.forms[0].action = "${basePath}/tax/role_delete.action?role.roleId="+id; document.forms[0].submit(); } //批量刪除 function doDeleteAll(){ document.forms[0].action = "${basePath}/tax/role_deleteSelected.action"; document.forms[0].submit(); } </script> </head> <body class="rightBody"> <form name="form1" action="" method="post"> <div class="p_d_1"> <div class="p_d_1_1"> <div class="content_info"> <div class="c_crumbs"><div><b></b><strong>角色管理 </strong></div> </div> <div class="search_art"> <li> 角色名稱:<s:textfield name="role.name" cssClass="s_text" id="roleName" cssStyle="width:160px;"/> </li> <li><input type="button" class="s_button" value="搜 索" onclick="doSearch()"/></li> <li > <input type="button" value="新增" class="s_button" onclick="doAdd()"/> <input type="button" value="刪除" class="s_button" onclick="doDeleteAll()"/> </li> </div> <div class="t_list" > <table width="100%" border="0"> <tr class="t_tit"> <td width="30" align="center"><input type="checkbox" id="selAll" onclick="doSelectAll()" /></td> <td width="120" align="center">角色名稱</td> <td align="center">權(quán)限</td> <td width="80" align="center">狀態(tài)</td> <td width="120" align="center">操作</td> </tr> <s:iterator value="roleList" status="vs"> <tr <s:if test="#vs.odd">bgcolor="f8f8f8"</s:if> > <td align="center"><input type="checkbox" name="selectedRow" value="<s:property value="roleId"/>"/></td> <td align="center"><s:property value="name"/></td> <td align="center"> <s:iterator value="rolePrivileges"> <s:property value="#privilegeMap[id.code]"/> </s:iterator> </td> <td align="center"> <s:if test="state == 1">有效</s:if><s:else>無效</s:else> </td> <td align="center"> <a href="javascript:doEdit('<s:property value="roleId"/>')">編輯</a> <a href="javascript:doDelete('<s:property value="roleId"/>')">刪除</a> </td> </tr> </s:iterator> </table> </div> </div> <div class="c_pate" > <table width="100%" class="pageDown" border="0" cellspacing="0" cellpadding="0"> <tr> <td align="right"> 總共1條記錄,當(dāng)前第 1 頁,共 1 頁 <a href="#">上一頁</a> <a href="#">下一頁</a> 到 <input type="text" onkeypress="if(event.keyCode == 13){doGoPage(this.value);}" min="1" max="" value="1" /> </td> </tr> </table> </div> </div> </div> </form> </body> </html>
知識點(diǎn)(1):從map當(dāng)中取數(shù)據(jù)
后臺代碼
//列表頁面 public String listUI(){ //加載權(quán)限集合 ActionContext.getContext().getContextMap().put("privilegeMap", PrivilegeStatics.PRIVILEGE_MAP); roleList = roleService.findAll(); return "listUI"; }
在JSP頁面取出privilegeMap對象中的數(shù)據(jù)
<s:iterator value="roleList" status="vs"> <s:iterator value="rolePrivileges"> <s:property value="#privilegeMap[id.code]"/> </s:iterator> </s:iterator>
知識點(diǎn)(2):
在定義的時候,雖然是String類型,但是在JSP頁面判斷的時候,似乎沒有區(qū)分
private String state;
<s:if test="state == 1">有效</s:if><s:else>無效</s:else>
2、addUI.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <%@include file="/common/header.jsp"%> <title>角色管理</title> </head> <body class="rightBody"> <form id="form" name="form" action="${basePath}/tax/role_add.action" method="post" enctype="multipart/form-data"> <div class="p_d_1"> <div class="p_d_1_1"> <div class="content_info"> <div class="c_crumbs"><div><b></b><strong>角色管理</strong> - 新增角色</div></div> <div class="tableH2">新增角色</div> <table id="baseInfo" width="100%" align="center" class="list" border="0" cellpadding="0" cellspacing="0" > <tr> <td class="tdBg" width="200px">角色名稱:</td> <td><s:textfield name="role.name" /></td> </tr> <tr> <td class="tdBg" width="200px">角色權(quán)限:</td> <td> <!-- This is just a detail of the Java Map API. Instead, it iterates over Entry objects. The Entry object has two properties, the key and the value. By default, the select component’s listKey attribute will be set to key. Also by default, the listValue attribute will be set to value. If you’re using Maps, you can sometimes accept these defaults. 因此,如果listKey="key"并且listValue="value",那么這兩個值可以省略。 另外,如果省略name屬性,會報錯! --> <s:checkboxlist list="#privilegeMap" name="privilegeIds" listKey="key" listValue="value"></s:checkboxlist> </td> </tr> <tr> <td class="tdBg" width="200px">狀態(tài):</td> <td><s:radio list="#{'1':'有效','0':'無效'}" name="role.state" value="1"/></td> </tr> </table> <div class="tc mt20"> <input type="submit" class="btnB2" value="保存" /> <input type="button" onclick="javascript:history.go(-1)" class="btnB2" value="返回" /> </div> </div></div></div> </form> </body> </html>
知識點(diǎn)(1):checklistbox
<!-- This is just a detail of the Java Map API. Instead, it iterates over Entry objects. The Entry object has two properties, the key and the value. By default, the select component’s listKey attribute will be set to key. Also by default, the listValue attribute will be set to value. If you’re using Maps, you can sometimes accept these defaults. 因此,如果listKey="key"并且listValue="value",那么這兩個值可以省略。 另外,如果省略name屬性,會報錯! --> <s:checkboxlist list="#privilegeMap" name="privilegeIds" listKey="key" listValue="value"></s:checkboxlist>
知識點(diǎn)(2):radio 有默認(rèn)值
<s:radio list="#{'1':'有效','0':'無效'}" name="role.state" value="1"/>
3、editUI.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" %> <html> <head> <%@include file="/common/header.jsp"%> <title>角色管理</title> </head> <body class="rightBody"> <form id="form" name="form" action="${basePath}/tax/role_edit.action" method="post" enctype="multipart/form-data"> <div class="p_d_1"> <div class="p_d_1_1"> <div class="content_info"> <div class="c_crumbs"><div><b></b><strong>角色管理</strong> - 編輯角色</div></div> <div class="tableH2">編輯角色</div> <table id="baseInfo" width="100%" align="center" class="list" border="0" cellpadding="0" cellspacing="0" > <tr> <td class="tdBg" width="200px">角色名稱:</td> <td><s:textfield name="role.name" /></td> </tr> <tr> <td class="tdBg" width="200px">角色權(quán)限:</td> <td> <s:checkboxlist list="privilegeMap" name="privilegeIds"></s:checkboxlist> </td> </tr> <tr> <td class="tdBg" width="200px">狀態(tài):</td> <td><s:radio list="#{'1':'有效','0':'無效'}" name="role.state"/></td> </tr> </table> <s:hidden name="role.roleId"/> <div class="tc mt20"> <input type="submit" class="btnB2" value="保存" /> <input type="button" onclick="javascript:history.go(-1)" class="btnB2" value="返回" /> </div> </div></div></div> </form> </body> </html>
知識點(diǎn)(1):radio 在編輯頁面,不需要設(shè)置默認(rèn)值,而是使用它的實(shí)際值
<s:radio list="#{'1':'有效','0':'無效'}" name="role.state"/>
文章標(biāo)題:SSH系列:(17)角色-權(quán)限管理(前臺JSP)
本文來源:http://jinyejixie.com/article8/gggdip.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供ChatGPT、全網(wǎng)營銷推廣、品牌網(wǎng)站制作、云服務(wù)器、微信小程序、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)