转自 http://heisetoufa.iteye.com/blog/227699
程序入口为
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>
- <%@ 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>
<%@ 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");
- }
- }
- /*
- * 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");
- }
- }
/*
* 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.