由后台的值来决定前台的复选框是否为默认选中,简单用户权限管理,html:multibox

例子下载,下载解压后自行导入struts包

程序入口为

http://localhost:8080/ShowPermission.do

下面贴代码

ShowPermission.jsp

<%@ page contentType="text/html; charset=gbk"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-bean" prefix="bean"%> 
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
 
<html> 
  <head>
 <title>JSP for ShowPermissionForm form</title>
  </head>
<style type="text/css">
table#list {
  border-top: 1px solid #000000;
  border-left: 1px solid #000000;
  border-collapse: collapse;
  font-size: 11pt;
}
table#list td, table#list th {
  border-bottom: 1px solid #000000;
  border-right: 1px solid #000000;
  padding-left: 5px;
  padding-right: 5px;
}
table#list thead tr {
  background-color: #0af0cd;
}
table#list td.permission {
  text-align: center;
  width: 70px;
}
</style>
  
  
  <body>
    <html:form action="/updatePermission" method="post">
    <table id="list" cellspacing="0">
      <thead>
        <tr>
          <td>选项</td>
          <td>姓名</td>
          <td width="100px">单位</td>
          <td width="100px">部门</td>
          <td>增加权限</td>
          <td>删除权限</td>
          <td>修改权限</td>
          <td>查看权限</td>
        </tr>
      </thead>
      <tbody>
        <c:forEach items="${emps}" var="emp">
        <tr>
          <td><input type="checkbox" name="empIds" value="${emp.empId}"></td>
          <td>${emp.name}</td>
          <td>${emp.unit}</td>
          <td>${emp.division}</td>
          <td><input type="checkbox" name="addPermissions" value="${emp.empId}"<c:if test="${emp.addPermission == '1'}"> checked</c:if> /></td>
          <td><input type="checkbox" name="deletePermissions" value="${emp.empId}"<c:if test="${emp.deletePermission == '1'}"> checked</c:if> /></td>
          <td><input type="checkbox" name="modifyPermissions" value="${emp.empId}"<c:if test="${emp.modifyPermission == '1'}"> checked</c:if> /></td>
          <td><input type="checkbox" name="viewPermissions" value="${emp.empId}"<c:if test="${emp.viewPermission == '1'}"> checked</c:if> /></td>          
        </tr>
        </c:forEach>
      </tbody>
    </table>
    <html:submit value="更新" />
    </html:form>
  </body>
</html>

 ShowPermissionAction

/*
 * Generated by MyEclipse Struts
 * Template path: templates/java/JavaClass.vtl
 */
package com.struts.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.bean.Employee;

public class ShowPermissionAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        List<Employee> emps = new ArrayList<Employee>();
        Employee emp1 = new Employee("001", "Enjoy",   "单位", "工程部", "0", "1", "1", "0");
        Employee emp2 = new Employee("002", "joejoe",   "单位", "工程部", "1", "0", "0", "0");
        Employee emp3 = new Employee("003", "koko",   "单位", "工程部", "1", "1", "1", "0");
        Employee emp4 = new Employee("004", "pizzame",   "单位", "工程部", "1", "0", "1", "1");
        Employee emp5 = new Employee("005", "heisetoufa",  "单位", "工程部", "1", "1", "0", "0");
        emps.add(emp1);
        emps.add(emp2);
        emps.add(emp3);
        emps.add(emp4);
        emps.add(emp5);
        
        for(Employee emp : emps) {
            System.out.println(emp);
        }
        
        request.setAttribute("emps", emps);
        return mapping.findForward("showPermission");
    }
}

 Employee

package com.bean;

public class Employee {

    private String empId;
    private String name;
    private String unit;
    private String division;
    private String addPermission;
    private String deletePermission;
    private String modifyPermission;
    private String viewPermission;
    
    public Employee(){
    }
    
    public Employee(String empId, String name, String unit, String division, String addPermission, String deletePermission, String modifyPermission, String viewPermission) {
        this.empId = empId;
        this.name = name;
        this.unit = unit;
        this.division = division;
        this.addPermission = addPermission;
        this.deletePermission = deletePermission;
        this.modifyPermission = modifyPermission;
        this.viewPermission = viewPermission;
    }
    public String getAddPermission() {
        return addPermission;
    }
    public void setAddPermission(String addPermission) {
        this.addPermission = addPermission;
    }
    public String getDeletePermission() {
        return deletePermission;
    }
    public void setDeletePermission(String deletePermission) {
        this.deletePermission = deletePermission;
    }
    public String getDivision() {
        return division;
    }
    public void setDivision(String division) {
        this.division = division;
    }
    public String getEmpId() {
        return empId;
    }
    public void setEmpId(String empId) {
        this.empId = empId;
    }
    public String getModifyPermission() {
        return modifyPermission;
    }
    public void setModifyPermission(String modifyPermission) {
        this.modifyPermission = modifyPermission;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getUnit() {
        return unit;
    }
    public void setUnit(String unit) {
        this.unit = unit;
    }
    public String getViewPermission() {
        return viewPermission;
    }
    public void setViewPermission(String viewPermission) {
        this.viewPermission = viewPermission;
    }
    public String toString() {
        return String.format("%-5s %-10s %-10s %-10s %-3s %-3s %-3s %-3s", empId, name, unit, division, addPermission, deletePermission, modifyPermission, viewPermission);
    }
    
}

 UpdatePermissionAction

package com.struts.action;

import java.util.ArrayList;
import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.bean.Employee;
import com.struts.form.UpdatePermissionForm;

public class UpdatePermissionAction extends Action {

    public ActionForward execute(ActionMapping mapping, ActionForm form,
            HttpServletRequest request, HttpServletResponse response) {
        UpdatePermissionForm update = (UpdatePermissionForm)form;
        String[] empIds = update.getEmpIds();
        String[] deletePermissions = update.getDeletePermissions();
        String[] addPermissions = update.getAddPermissions();
        String[] modifyPermissions = update.getModifyPermissions();        
        String[] viewPermissions = update.getViewPermissions();
        
        
        List<Employee> updateEmps = new ArrayList<Employee>();
        for(int i = 0; i < empIds.length; i++) {
            Employee emp = new Employee();
            String empId = empIds[i];
            emp.setEmpId(empId);
            emp.setAddPermission(hasPermission(empId, addPermissions));
            emp.setDeletePermission(hasPermission(empId, deletePermissions));
            emp.setModifyPermission(hasPermission(empId, modifyPermissions));
            emp.setViewPermission(hasPermission(empId, viewPermissions));
            updateEmps.add(emp);
        }
        
        // 更新 updateEmps 中的数据
        
        // 重新从数据库中查出所有的
        request.setAttribute("emps", updateEmps);
        
        /// 测试用
        System.out.println("===== update =====");
        for(Employee emp : updateEmps) {
            System.out.println(emp);
        }      
        
        return mapping.findForward("showPermission");
    }
    
    private String hasPermission(String empId, String[] permissions) {
        if(permissions == null) {
            return "0";
        }
        for(int i = 0; i < permissions.length; i++) {
            if(empId.equals(permissions[i])) {
                return "1";
            }
        }
        return "0";
    }
}

 UpdatePermissionForm

package com.struts.form;

import javax.servlet.http.HttpServletRequest;
import org.apache.struts.action.ActionErrors;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

public class UpdatePermissionForm extends ActionForm {
    private static final long serialVersionUID = 1L;
    private String[] empIds;
    private String[] addPermissions;
    private String[] deletePermissions;
    private String[] modifyPermissions;
    private String[] viewPermissions;

    public String[] getAddPermissions() {
        return addPermissions;
    }

    public void setAddPermissions(String[] addPermissions) {
        this.addPermissions = addPermissions;
    }

    public String[] getDeletePermissions() {
        return deletePermissions;
    }

    public void setDeletePermissions(String[] deletePermissions) {
        this.deletePermissions = deletePermissions;
    }

    public String[] getEmpIds() {
        return empIds;
    }

    public void setEmpIds(String[] empIds) {
        this.empIds = empIds;
    }

    public String[] getModifyPermissions() {
        return modifyPermissions;
    }

    public void setModifyPermissions(String[] modifyPermissions) {
        this.modifyPermissions = modifyPermissions;
    }

    public String[] getViewPermissions() {
        return viewPermissions;
    }

    public void setViewPermissions(String[] viewPermissions) {
        this.viewPermissions = viewPermissions;
    }

    public ActionErrors validate(ActionMapping mapping,
            HttpServletRequest request) {
        // TODO Auto-generated method stub
        return null;
    }

    public void reset(ActionMapping mapping, HttpServletRequest request) {
        // TODO Auto-generated method stub
    }
}

 struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
  <data-sources />
  <form-beans >
    <form-bean name="updatePermissionForm" type="com.struts.form.UpdatePermissionForm" />

  </form-beans>

  <global-exceptions />
  <global-forwards />
  <action-mappings >
    <action
      path="/showPermission"
      scope="request"
      type="com.struts.action.ShowPermissionAction"
      validate="false" >
      <forward name="showPermission" path="/showPermission.jsp" />
    </action>
    
    <action
      attribute="updatePermissionForm"
      name="updatePermissionForm"
      path="/updatePermission"
      scope="request"
      type="com.struts.action.UpdatePermissionAction"
      validate="false" >
      <forward name="showPermission" path="/showPermission.jsp" />
    </action>


  </action-mappings>

  <message-resources parameter="com.struts.ApplicationResources" />
</struts-config>

 -----------以上是测试用的,没有通过数据库---------------------------------------------

-----------下面是可以通过数据库用的--------------------------------------------

KK_BlacklistVehicle_UserManage_YhQx.jsp

<%@ page language="java" pageEncoding="gbk"%>

<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>
<%@ taglib uri="http://struts.apache.org/tags-tiles" prefix="tiles" %>
<%@ taglib uri="/tags/c" prefix="c" %>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html:html lang="true">
  <head>
    <html:base />
    
    <title>用户权限管理</title>
 
 <meta http-equiv="pragma" content="no-cache">
 <meta http-equiv="cache-control" content="no-cache">
 <meta http-equiv="expires" content="0">    
 <meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
 <meta http-equiv="description" content="This is my page">
 <link rel="stylesheet" type="text/css" href="css/styles.css">
<script language="javascript" type="text/javascript">
function YhQxKzUpdate()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?yhQxKzUpdateKeyUp=have' ;
 document.forms[0].submit();
}
function kk_BlacklistVehicle_UserManage_YhQxKz_IDCR()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_IDCR=have' ;
 document.forms[0].submit();
}
function kk_BlacklistVehicle_UserManage_YhQxKz_noIDCR()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_noIDCR=have' ;
 document.forms[0].submit();
}

function kk_BlacklistVehicle_UserManage_YhQxKz_IDSC()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_IDSC=have' ;
 document.forms[0].submit();
}

function kk_BlacklistVehicle_UserManage_YhQxKz_noIDSC()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_noIDSC=have' ;
 document.forms[0].submit();
}

function kk_BlacklistVehicle_UserManage_YhQxKz_IDCK()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_IDCK=have' ;
 document.forms[0].submit();
}

function kk_BlacklistVehicle_UserManage_YhQxKz_noIDCK()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_noIDCK=have' ;
 document.forms[0].submit();
}

function kk_BlacklistVehicle_UserManage_YhQxKz_IDZX()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_IDZX=have' ;
 document.forms[0].submit();
}

function kk_BlacklistVehicle_UserManage_YhQxKz_noIDZX()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_noIDZX=have' ;
 document.forms[0].submit();
}

function kk_BlacklistVehicle_UserManage_YhQxKz_IDCJ()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_IDCJ=have' ;
 document.forms[0].submit();
}

function kk_BlacklistVehicle_UserManage_YhQxKz_noIDCJ()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_noIDCJ=have' ;
 document.forms[0].submit();
}

function kk_BlacklistVehicle_UserManage_YhQxKz_DWIDCJ()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_DWIDCJ=have' ;
 document.forms[0].submit();
}

function kk_BlacklistVehicle_UserManage_YhQxKz_noDWIDCJ()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?kk_BlacklistVehicle_UserManage_YhQxKz_noDWIDCJ=have' ;
 document.forms[0].submit();
}

function YhQxKz_DeleteID()
{
 document.forms[0].action='KK_BlacklistVehicle_UserManage_YhQxKz.do?yhQxKz_DeleteID=have' ;
 document.forms[0].submit();
}

function KK_BlacklistVehicle_UserManage_YhQxKz_Return()
{
 window.location.href = "KK_BlacklistVehicle_UserManage.do";
}
function KK_BlacklistVehicle_UserManage_YhQxKz_BackOut()
{
 window.location.href = "BackOut.jsp" ;
}
function KK_BlacklistVehicleRegister_SelectPage_ReturnKKBJ()
{
 document.forms[0].action='KK_BlacklistVehicleAlarm.do' ;
 document.forms[0].submit();
}
</script>
  </head>
  
  <body>
  <table width='100%'>
 <tr>
 <td><div align='left'>
 <logic:notEmpty name="sessionDw" scope="session">
 对 <bean:write name="sessionDw" scope="session" /> 单位下</logic:notEmpty>用户权限的管理:
</div></td>
<td ><div align='right'>
<FONT size="2"><b><html:link page="/KK_BlacklistVehicle_Index.jsp">首页</html:link></b></FONT>
<html:button property="KK_BlacklistVehicleRegister_SelectPage_ReturnButton" onclick="KK_BlacklistVehicleRegister_SelectPage_ReturnKKBJ();">返回卡口报警</html:button>
    <html:button property="KK_BlacklistVehicle_UserManage_YhQxKz_ReturnButton" onclick="KK_BlacklistVehicle_UserManage_YhQxKz_Return();">返回</html:button>
 <html:button property="KK_BlacklistVehicle_UserManage_YhQxKz_BackOutButton" onclick="KK_BlacklistVehicle_UserManage_YhQxKz_BackOut();">退出</html:button>
</div></td>
 </tr>
 </table>
 <hr>
  <html:errors property="errorKK_BlacklistVehicle_UserManage_YhQxKz"/>
  <html:form action="/KK_BlacklistVehicle_UserManage_YhQxKz.do" method="post">
 <table border="1" width='100%' height='55%' height='70%' cellspacing="0" cellpadding="0" bordercolor="#FFFFFF" bordercolorlight="#000000" >
  <tr>
   
   <td>
    选中修改权限
   </td>
   <td>
    用户名
   </td>
   <td>
    单位
   </td>
   <td>
    部门
   </td>
   <td>
    添加权限
   </td>
   <td>
    查看权限
   </td>
   <td>
    删除权限
   </td>
   <td>
    超级查看权限
   </td>
   <td>
    超级用户权限
   </td>
   <td>
    单位超级用户权限
   </td>
   <td>
    删除
   </td>
  
  </tr>
  
  <logic:present name="list">
   <logic:iterate id="element" name="list" >
   
  <tr>
     <td>
      <html:multibox property="kk_BlacklistVehicle_UserManage_YhQxKzCheckBox">
       <bean:write name="element" property="id" />
      </html:multibox>
     </td>
     <td>
      <logic:empty name="element" property="id"> </logic:empty>
      <a href="KK_BlacklistVehicle_UserManage_BMQX.do?uid=<bean:write name="element" property="id"/>"/><bean:write name="element" property="id" /></a>
     </td>
     <td>
      <logic:empty name="element" property="dw"> </logic:empty> 
      <bean:write name="element" property="dw" />
     </td>
     <td>
      <logic:empty name="element" property="bm"> </logic:empty> 
      <bean:write name="element" property="bm" />
     </td>
     <td>
      <logic:empty name="element" property="idcr"> </logic:empty>
      <input type="checkbox" name="yhQxKzIdcr" value="${element.id}" <c:if test="${element.idcr == '1'}"> checked</c:if> />
     </td>
     <td>
      <logic:empty name="element" property="idck"> </logic:empty> 
      <input type="checkbox" name="yhQxKzIdck" value="${element.id}" <c:if test="${element.idck == '1'}"> checked</c:if> />
     </td>
     <td>
      <logic:empty name="element" property="idsc"> </logic:empty>
      <input type="checkbox" name="yhQxKzIdsc" value="${element.id}" <c:if test="${element.idsc == '1'}"> checked</c:if> />
     </td>
     <td>
      <logic:empty name="element" property="idzx"> </logic:empty>
      <input type="checkbox" name="yhQxKzIdzx" value="${element.id}" <c:if test="${element.idzx == '1'}"> checked</c:if> />
     </td>
     <td>
      <logic:empty name="element" property="idcj"> </logic:empty>
      <input type="checkbox" name="yhQxKzIdcj" value="${element.id}" <c:if test="${element.idcj == '1'}"> checked</c:if> />
     </td>
     <td>
      <logic:empty name="element" property="dwidcj"> </logic:empty>
      <input type="checkbox" name="yhQxKzDwidcj" value="${element.id}" <c:if test="${element.dwidcj == '1'}"> checked</c:if> />
     </td>
     <td>
      <a href="KK_BlacklistVehicle_UserManage_YhQxKz.do?yhQxKz_DeleteID_One=<bean:write name="element" property="id"/>"/>删除</a>
     </td>
     
     </tr>
   </logic:iterate>

  </logic:present>

 </table>
 
 <br>
 
 <html:button property="yhQxKzUpdate" onclick="YhQxKzUpdate();">修改</html:button>
 <html:button property="yhQxKz_DeleteId" onclick="YhQxKz_DeleteID();">删除选中用户</html:button>

 <logic:equal name="sessionIDCJ" scope="session" value="11234aasdfbjk43kadfjvmkeadfadfasdfasdfafasdfasdfef54df51ad5f1a5sdf56asd1f564fasd4f">
 
 
  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_IDCR();">有 添 加 权 限</html:button>
  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_noIDCR();">无 添 加 权 限</html:button>

  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_IDSC();">有 删 除 权 限</html:button>
  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_noIDSC();">无 删 除 权 限</html:button>
  <br>
  <br>
  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_IDCK();">有普通查看权限</html:button>
  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_noIDCK();">无普通查看权限</html:button>

  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_IDZX();">有超级查看权限</html:button>
  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_noIDZX();">无超级查看权限</html:button>
  <br>
  <br>
  
  
   <logic:equal name="sessionIDCJ" scope="session" value="1">
   
  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_IDCJ();">有超级管理权限</html:button>
  
    <logic:equal name="sessionIDCJ" scope="session" value="1234567890abcdefghijklmnopqrstuvwwxyz~!@#$%^&*()_+">
     <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="noIDCJ();"></html:button>
    </logic:equal>
  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_DWIDCJ();">有单位超级管理权限</html:button>
  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_noDWIDCJ();">无单位超级管理权限</html:button>
  <br>
  <br>
   </logic:equal>
   
   <logic:notEqual name="sessionIDCJ" scope="session" value="1">
    <logic:equal name="sessionDWIDCJ" scope="session" value="1">
    <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_DWIDCJ();">有单位超级管理权限</html:button>
  <html:button property="kk_BlacklistVehicle_UserManage_YhQxKz_UpdateButton" onclick="kk_BlacklistVehicle_UserManage_YhQxKz_noDWIDCJ();">无单位超级管理权限</html:button>
    </logic:equal>
   </logic:notEqual>
</logic:equal>
  
   <html:button property="yhQxKz_DeleteId" onclick="YhQxKz_DeleteID();">删除选中用户</html:button>


</html:form>
 <html:link page="/KK_BlacklistVehicle_UserManage_YhQxKz.do?action=firstPage">首页</html:link>
 
 <logic:equal name="KK_BlacklistVehicle_UserManage_YhQxKz" property="hasPreviousPage" value="true">
  <html:link page="/KK_BlacklistVehicle_UserManage_YhQxKz.do?action=previousPage">上一页</html:link>
 </logic:equal>
 
 <logic:notEqual name="KK_BlacklistVehicle_UserManage_YhQxKz" property="hasPreviousPage" value="true">
 上一页
 </logic:notEqual>
 
 
 <logic:equal name="KK_BlacklistVehicle_UserManage_YhQxKz" property="hasNextPage" value="true">
  <html:link page="/KK_BlacklistVehicle_UserManage_YhQxKz.do?action=nextPage">下一页</html:link>
 </logic:equal>
 
 <logic:notEqual name="KK_BlacklistVehicle_UserManage_YhQxKz" property="hasNextPage" value="true">
 下一页
 </logic:notEqual>
 
 
 
 
 
<html:link page="/KK_BlacklistVehicle_UserManage_YhQxKz.do?action=lastPage">末页</html:link>
<form action="KK_BlacklistVehicle_UserManage_YhQxKz.do?action=goto" method="post">

输入要跳转的页数:<input type="text" name="kk_BlacklistVehicle_UserManage_YhQxKzGoto" style="ime-mode:disabled" onkeydown="onlyNum();" />
<input type="submit" value="goto"/>

 

</form>
总共<bean:write name="KK_BlacklistVehicle_UserManage_YhQxKz" property="totalRows"/>行,
一共<bean:write name="KK_BlacklistVehicle_UserManage_YhQxKz" property="totalPages"/>页,
当前是第<bean:write name="KK_BlacklistVehicle_UserManage_YhQxKz" property="currentPage"/>页
  
  </body>
</html:html>

struts-config.xml

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE struts-config PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 1.2//EN" "http://struts.apache.org/dtds/struts-config_1_2.dtd">

<struts-config>
  <data-sources />
  <form-beans >
 <form-bean name="KK_BlacklistVehicle_UserManage_YhQxKzForm"  type="struts.form.KK_BlacklistVehicle_UserManage_YhQxKzForm" /> 
  </form-beans>
  <global-exceptions />
  <global-forwards >
  </global-forwards>
  <action-mappings>
<action
    attribute="KK_BlacklistVehicle_UserManage_YhQxKzForm"
      input="/KK_BlacklistVehicle_UserManage_YhQx.jsp"
      name="KK_BlacklistVehicle_UserManage_YhQxKzForm"
      path="/KK_BlacklistVehicle_UserManage_YhQxKz"
      scope="request"
      type="struts.action.KK_BlacklistVehicle_UserManage_YhQxKzAction"
      validate="true">
      <forward name="KK_BlacklistVehicle_UserManage_YhQxKzSucceed" path="/KK_BlacklistVehicle_UserManage_YhQx.jsp" />
      
    </action>
</action-mappings>
  <message-resources parameter="struts.ApplicationResources" />
</struts-config>

 KK_BlacklistVehicle_UserManage_YhQxKzAction

//用户权限
package struts.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import struts.form.KK_BlacklistVehicle_UserManage_YhQxKzForm;
import util.KK_BlacklistVehicle_UserManage_DwQxPager;
import bean.KK_BlacklistVehicle_UserManage_YhQxKzSQLBean;

public class KK_BlacklistVehicle_UserManage_YhQxKzAction extends Action 
{
 private KK_BlacklistVehicle_UserManage_DwQxPager kk_BlacklistVehicle_UserManage_DwQxPager;
 
 private List list;
 
 public ActionForward execute(ActionMapping mapping, ActionForm form,
   HttpServletRequest request, HttpServletResponse response) 
 {
//  判断用户退出后不允许进行操作,返回至登陆页面
  if (request.getSession().getAttribute("sessionKK_BlacklistVehicle_UserLogin_ID")==null||"".equals(request.getSession().getAttribute("sessionKK_BlacklistVehicle_UserLogin_ID"))) 
     {
   return mapping.findForward("back");
     }
  else
  {
   
  }
  HttpSession session = request.getSession();
  String sessionIDCJ = (String)session.getAttribute("sessionIDCJ");//用户超级权限
  if(!sessionIDCJ.equals("1"))
  {
   return mapping.findForward("KK_BlacklistVehicle_UserNoManage_Succeed");
  }
  KK_BlacklistVehicle_UserManage_YhQxKzForm kk_BlacklistVehicle_UserManage_YhQxKzForm = (KK_BlacklistVehicle_UserManage_YhQxKzForm) form;
  
  String[] kk_BlacklistVehicle_UserManage_YhQxKzCheckBox = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKzCheckBox();
  String kk_BlacklistVehicle_UserManage_YhQxKz_IDCR = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_IDCR();
  String kk_BlacklistVehicle_UserManage_YhQxKz_noIDCR = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_noIDCR();
  String kk_BlacklistVehicle_UserManage_YhQxKz_IDSC = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_IDSC();
  String kk_BlacklistVehicle_UserManage_YhQxKz_noIDSC = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_noIDSC();
  String kk_BlacklistVehicle_UserManage_YhQxKz_IDCK = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_IDCK();
  String kk_BlacklistVehicle_UserManage_YhQxKz_noIDCK = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_noIDCK();
  String kk_BlacklistVehicle_UserManage_YhQxKz_IDZX = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_IDZX();
  String kk_BlacklistVehicle_UserManage_YhQxKz_noIDZX = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_noIDZX();
  String kk_BlacklistVehicle_UserManage_YhQxKz_IDCJ = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_IDCJ() ;
  String kk_BlacklistVehicle_UserManage_YhQxKz_noIDCJ = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_noIDCJ() ;
  String kk_BlacklistVehicle_UserManage_YhQxKz_DWIDCJ = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_DWIDCJ() ;
  String kk_BlacklistVehicle_UserManage_YhQxKz_noDWIDCJ = kk_BlacklistVehicle_UserManage_YhQxKzForm.getKk_BlacklistVehicle_UserManage_YhQxKz_noDWIDCJ() ;
  String yhQxKz_DeleteID = kk_BlacklistVehicle_UserManage_YhQxKzForm.getYhQxKz_DeleteID() ;
  String yhQxKz_DeleteID_One = kk_BlacklistVehicle_UserManage_YhQxKzForm.getYhQxKz_DeleteID_One() ;
  
  String yhQxKzUpdateKeyUp = kk_BlacklistVehicle_UserManage_YhQxKzForm.getYhQxKzUpdateKeyUp() ;
  
  String[] yhQxKzIdcr = kk_BlacklistVehicle_UserManage_YhQxKzForm.getYhQxKzIdcr() ;
  String[] yhQxKzIdck = kk_BlacklistVehicle_UserManage_YhQxKzForm.getYhQxKzIdck() ;
  String[] yhQxKzIdsc = kk_BlacklistVehicle_UserManage_YhQxKzForm.getYhQxKzIdsc() ;
  String[] yhQxKzIdzx = kk_BlacklistVehicle_UserManage_YhQxKzForm.getYhQxKzIdzx() ;
  String[] yhQxKzIdcj = kk_BlacklistVehicle_UserManage_YhQxKzForm.getYhQxKzIdcj() ;
  String[] yhQxKzDwidcj = kk_BlacklistVehicle_UserManage_YhQxKzForm.getYhQxKzDwidcj() ;
  
  String sessionDw = (String)session.getAttribute("sessionDw");//单位管理页面点击的单位
  
  String action=null;
  action=request.getParameter("action");
  try
  {
   KK_BlacklistVehicle_UserManage_YhQxKzSQLBean kk_BlacklistVehicle_UserManage_YhQxKzSQLBean = new KK_BlacklistVehicle_UserManage_YhQxKzSQLBean();
   
   if(action==null||action.equals("null"))
   {
    if(kk_BlacklistVehicle_UserManage_YhQxKz_IDCR!=null)
    {
     //判断是否点的设置插入权限按钮
     try 
     {
      if(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null||(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null&&kk_BlacklistVehicle_UserManage_YhQxKzCheckBox.length!=0))
      {
       list = kk_BlacklistVehicle_UserManage_YhQxKzSQLBean.isInsertKK_BlacklistVehicle_UserManage_YhQxKzSQLBean(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox,sessionDw);
       //设置有添加权限
       if(list.size()!=0)
       {
        kk_BlacklistVehicle_UserManage_DwQxPager=new KK_BlacklistVehicle_UserManage_DwQxPager(list);
        list=kk_BlacklistVehicle_UserManage_DwQxPager.getPageList();
        request.setAttribute("list", list);
        request.setAttribute("KK_BlacklistVehicle_UserManage_YhQxKz", kk_BlacklistVehicle_UserManage_DwQxPager);
       }
       else
       {
//        System.out.println("没有可显示的数据");
        return mapping.getInputForward() ;
       }
      }
     }
     catch (Exception e)
     {
      e.printStackTrace() ;
      return mapping.findForward("ErrorCallAdmin");
     }
    }
    
    if(kk_BlacklistVehicle_UserManage_YhQxKz_noIDCR!=null)
    {
     try 
     {
      if(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null||(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null&&kk_BlacklistVehicle_UserManage_YhQxKzCheckBox.length!=0))
      {
       list = kk_BlacklistVehicle_UserManage_YhQxKzSQLBean.isNoInsertKK_BlacklistVehicle_UserManage_YhQxKzSQLBean(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox,sessionDw);
       //设置没有添加权限
       if(list.size()!=0)
       {
        kk_BlacklistVehicle_UserManage_DwQxPager=new KK_BlacklistVehicle_UserManage_DwQxPager(list);
        list=kk_BlacklistVehicle_UserManage_DwQxPager.getPageList();
        request.setAttribute("list", list);
        request.setAttribute("KK_BlacklistVehicle_UserManage_YhQxKz", kk_BlacklistVehicle_UserManage_DwQxPager);
       }
       else
       {
//        System.out.println("没有可显示的数据");
        return mapping.getInputForward() ;
       }
      }
     }
     catch (Exception e)
     {
      e.printStackTrace() ;
      return mapping.findForward("ErrorCallAdmin");
     }
    }
    if(kk_BlacklistVehicle_UserManage_YhQxKz_IDSC!=null)
    {
     try 
     {
      if(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null||(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null&&kk_BlacklistVehicle_UserManage_YhQxKzCheckBox.length!=0))
      {
       list = kk_BlacklistVehicle_UserManage_YhQxKzSQLBean.isDeleteKK_BlacklistVehicle_UserManage_YhQxKzSQLBean(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox,sessionDw);
       //设置有删除权限
       if(list.size()!=0)
       {
        kk_BlacklistVehicle_UserManage_DwQxPager=new KK_BlacklistVehicle_UserManage_DwQxPager(list);
        list=kk_BlacklistVehicle_UserManage_DwQxPager.getPageList();
        request.setAttribute("list", list);
        request.setAttribute("KK_BlacklistVehicle_UserManage_YhQxKz", kk_BlacklistVehicle_UserManage_DwQxPager);
       }
       else
       {
//        System.out.println("没有可显示的数据");
        return mapping.getInputForward() ;
       }
      }
     }
     catch (Exception e)
     {
      e.printStackTrace() ;
      return mapping.findForward("ErrorCallAdmin");
     }
    }
    
    if(kk_BlacklistVehicle_UserManage_YhQxKz_noIDSC!=null)
    {
     try 
     {
      if(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null||(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null&&kk_BlacklistVehicle_UserManage_YhQxKzCheckBox.length!=0))
      {
       list = kk_BlacklistVehicle_UserManage_YhQxKzSQLBean.isNoDeleteKK_BlacklistVehicle_UserManage_YhQxKzSQLBean(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox,sessionDw);
       //设置没有删除权限
       if(list.size()!=0)
       {
        kk_BlacklistVehicle_UserManage_DwQxPager=new KK_BlacklistVehicle_UserManage_DwQxPager(list);
        list=kk_BlacklistVehicle_UserManage_DwQxPager.getPageList();
        request.setAttribute("list", list);
        request.setAttribute("KK_BlacklistVehicle_UserManage_YhQxKz", kk_BlacklistVehicle_UserManage_DwQxPager);
       }
       else
       {
//        System.out.println("没有可显示的数据");
        return mapping.getInputForward() ;
       }
      }
     }
     catch (Exception e)
     {
      e.printStackTrace() ;
      return mapping.findForward("ErrorCallAdmin");
     }
    }
    
    if(kk_BlacklistVehicle_UserManage_YhQxKz_IDCK!=null)
    {
     try 
     {
      if(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null||(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null&&kk_BlacklistVehicle_UserManage_YhQxKzCheckBox.length!=0))
      {
       list = kk_BlacklistVehicle_UserManage_YhQxKzSQLBean.isSelectKK_BlacklistVehicle_UserManage_YhQxKzSQLBean(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox,sessionDw);
       //设置有查看权限
       if(list.size()!=0)
       {
        kk_BlacklistVehicle_UserManage_DwQxPager=new KK_BlacklistVehicle_UserManage_DwQxPager(list);
        list=kk_BlacklistVehicle_UserManage_DwQxPager.getPageList();
        request.setAttribute("list", list);
        request.setAttribute("KK_BlacklistVehicle_UserManage_YhQxKz", kk_BlacklistVehicle_UserManage_DwQxPager);
       }
       else
       {
//        System.out.println("没有可显示的数据");
        return mapping.getInputForward() ;
       }
      }
     }
     catch (Exception e)
     {
      e.printStackTrace() ;
      return mapping.findForward("ErrorCallAdmin");
     }
    }
    
    if(kk_BlacklistVehicle_UserManage_YhQxKz_noIDCK!=null)
    {
     try 
     {
      if(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null||(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null&&kk_BlacklistVehicle_UserManage_YhQxKzCheckBox.length!=0))
      {
       list = kk_BlacklistVehicle_UserManage_YhQxKzSQLBean.isNoSelectKK_BlacklistVehicle_UserManage_YhQxKzSQLBean(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox,sessionDw);
       //设置没有查看权限
       if(list.size()!=0)
       {
        kk_BlacklistVehicle_UserManage_DwQxPager=new KK_BlacklistVehicle_UserManage_DwQxPager(list);
        list=kk_BlacklistVehicle_UserManage_DwQxPager.getPageList();
        request.setAttribute("list", list);
        request.setAttribute("KK_BlacklistVehicle_UserManage_YhQxKz", kk_BlacklistVehicle_UserManage_DwQxPager);
       }
       else
       {
//        System.out.println("没有可显示的数据");
        return mapping.getInputForward() ;
       }
      }
     }
     catch (Exception e)
     {
      e.printStackTrace() ;
      return mapping.findForward("ErrorCallAdmin");
     }
    }
    
    if(kk_BlacklistVehicle_UserManage_YhQxKz_IDZX!=null)
    {
     try 
     {
      if(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null||(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null&&kk_BlacklistVehicle_UserManage_YhQxKzCheckBox.length!=0))
      {
       list = kk_BlacklistVehicle_UserManage_YhQxKzSQLBean.isSelectKK_BlacklistVehicle_UserManage_YhQxKzSQLBean_IDZX(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox,sessionDw);
       //设置有超级查看权限
       if(list.size()!=0)
       {
        kk_BlacklistVehicle_UserManage_DwQxPager=new KK_BlacklistVehicle_UserManage_DwQxPager(list);
        list=kk_BlacklistVehicle_UserManage_DwQxPager.getPageList();
        request.setAttribute("list", list);
        request.setAttribute("KK_BlacklistVehicle_UserManage_YhQxKz", kk_BlacklistVehicle_UserManage_DwQxPager);
       }
       else
       {
//        System.out.println("没有可显示的数据");
        return mapping.getInputForward() ;
       }
      }
     }
     catch (Exception e)
     {
      e.printStackTrace() ;
      return mapping.findForward("ErrorCallAdmin");
     }
    }
    
    if(kk_BlacklistVehicle_UserManage_YhQxKz_noIDZX!=null)
    {
     try 
     {
      if(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null||(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox!=null&&kk_BlacklistVehicle_UserManage_YhQxKzCheckBox.length!=0))
      {
       list = kk_BlacklistVehicle_UserManage_YhQxKzSQLBean.isNoSelectKK_BlacklistVehicle_UserManage_YhQxKzSQLBean_IDZX(kk_BlacklistVehicle_UserManage_YhQxKzCheckBox,sessionDw);
       //设置没有超级查看权限
       if(list.size()!=0)
       {
        kk_BlacklistVehicle_UserManage_DwQxPager=new KK_BlacklistVehicle_UserManage_DwQxPager(list);
        list=kk_BlacklistVehicle_UserManage_DwQxPager.getPageList();
        request.setAttribute("list", list);
        request.setAttribute("KK_BlacklistVehicle_UserManage_YhQxKz", kk_BlacklistVehicle_UserManage_DwQxPager);
       }
       else
       {
//        System.out.println("没有可显示的数据");
        return mapping.getInputForward() ;
       }
      }
     }
     catch (Exception e)
     {
      e.printStackTrace() ;
      return mapping.findForward("ErrorCallAdmin");
     }
    }
    
    
    if(yhQxKz_DeleteID_One!=null)
    {
     try 
     {
      list = kk_BlacklistVehicle_UserManage_YhQxKzSQLBean.yhQxKz_DeleteID_One(yhQxKz

 

黑色头发  http://heisetoufa.iteye.com

你可能感兴趣的:(apache,html,bean,struts,C#)