采用DispathAction
* 如果覆写DispathAction中的execute方法,必须显示的用super调用execute方法
* parameter参数值不能是execute或perform
* 了解<action>标签中的parameter的含义
* 了解DispathAction中的unspecified方法的含义
struts-config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<form-beans>
<form-bean name="userForm" type="com.bjsxt.drp.web.usermgr.forms.UserActionForm"></form-bean>
</form-beans>
<global-forwards>
<forward name="success" path="/user/usermaint.do" redirect="true"/>
</global-forwards>
<action-mappings>
<action path="/user/usermaint"
type="com.bjsxt.drp.web.usermgr.actions.UserAction"
name="userForm"
scope="request"
parameter="command"
>
<!--
<forward name="add_success" path="/user/usermaint.do?command=list" redirect="true"/>
<forward name="del_success" path="/user/usermaint.do?command=list" redirect="true"/>
<forward name="modify_success" path="/user/usermaint.do?command=list" redirect="true"/>
-->
<forward name="find_success" path="/user/user_modify.jsp"/>
<forward name="list_success" path="/user/user_list.jsp"/>
</action>
<!--
<action
path="/user/add"
type="com.bjsxt.drp.web.usermgr.actions.AddUserAction"
name="userForm"
scope="request"
>
<forward name="success" path="/user/list.do" redirect="true"></forward>
</action>
<action
path="/user/del"
type="com.bjsxt.drp.web.usermgr.actions.DelUserAction"
name="userForm"
scope="request"
>
<forward name="success" path="/user/list.do" redirect="true"></forward>
</action>
<action
path="/user/list"
type="com.bjsxt.drp.web.usermgr.actions.ListUserAction"
name="userForm"
scope="request"
>
<forward name="success" path="/user/user_list.jsp"></forward>
</action>
<action
path="/user/find"
type="com.bjsxt.drp.web.usermgr.actions.FindUserAction"
name="userForm"
scope="request"
>
<forward name="success" path="/user/user_modify.jsp"></forward>
</action>
<action
path="/user/modify"
type="com.bjsxt.drp.web.usermgr.actions.ModifyUserAction"
name="userForm"
scope="request"
>
<forward name="success" path="/user/list.do" redirect="true"></forward>
</action>
-->
</action-mappings>
<message-resources parameter="MessageResources" />
</struts-config>
DB.java
package com.bjsxt.drp.business.util;
import java.sql.*;
public class DB {
public static Connection getConn() {
Connection conn = null;
try {
Class.forName("com.mysql.jdbc.Driver");
conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/drp?user=root&password=123");
} catch (ClassNotFoundException e) {
e.printStackTrace();
} catch (SQLException e) {
e.printStackTrace();
}
return conn;
}
public static void closeConn(Connection conn) {
try {
if(conn != null) {
conn.close();
conn = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void closeStmt(Statement stmt) {
try {
if(stmt != null) {
stmt.close();
stmt = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
public static void closeRs(ResultSet rs) {
try {
if(rs != null) {
rs.close();
rs = null;
}
} catch (SQLException e) {
e.printStackTrace();
}
}
}
User.java
package com.bjsxt.drp.business.usermgr.model;
import java.util.Date;
/**
* 用户实体类
* @author Administrator
*
*/
public class User {
//用户代码
private String userId;
//用户名称
private String userName;
//密码
private String password;
//联系电话
private String contactTel;
//email
private String email;
//创建日期
private Date createDate;
public String getContactTel() {
return contactTel;
}
public void setContactTel(String contactTel) {
this.contactTel = contactTel;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
}
UserDao4MySqlImpl.java
package com.bjsxt.drp.business.usermgr.dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
import com.bjsxt.drp.business.usermgr.model.User;
import com.bjsxt.drp.business.util.DB;
/**
* 用户增删改查Dao层MySql实现
*
*/
public class UserDao4MySqlImpl implements UserDao {
/**
* 增加用户
* @param conn
* @param user user对象
*/
public void addUser(Connection conn, User user) {
String sql = "insert into t_user(user_id, user_name, password, contact_tel, email, create_date) "
+ "values(?, ?, ?, ?, ?, ?)";
PreparedStatement pstmt = null;
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, user.getUserId());
pstmt.setString(2, user.getUserName());
pstmt.setString(3, user.getPassword());
pstmt.setString(4, user.getContactTel());
pstmt.setString(5, user.getEmail());
pstmt.setTimestamp(6, new Timestamp(user.getCreateDate().getTime()));
pstmt.executeUpdate();
} catch (SQLException e) {
e.printStackTrace();
} finally {
DB.closeStmt(pstmt);
}
}
/**
* 根据userId的集合删除用户
* @param conn
* @param userIdList userId的集合
*/
public void deleteUsers(Connection conn, String[] userIdList) {
StringBuffer sbfSql = new StringBuffer();
for (int i = 0; i < userIdList.length; i++) {
sbfSql.append("'")
.append(userIdList[i])
.append("'")
.append(",");
}
String sql = "delete from t_user where user_id in (" + sbfSql.substring(0, sbfSql.length()-1) + ")";
Statement stmt = null;
try {
stmt = conn.createStatement();
stmt.executeUpdate(sql);
}catch(SQLException e) {
e.printStackTrace();
}finally {
DB.closeStmt(stmt);
DB.closeConn(conn);
}
}
/**
* 查询所有用户
* @return user对象列表
*/
public List findAllUserList() {
String sql ="select * from t_user where user_id <> 'root' order by user_id ";
Connection conn = null;
Statement stmt = null;
ResultSet rs = null;
List userList = new ArrayList();
try {
conn = DB.getConn();
stmt = conn.createStatement();
rs = stmt.executeQuery(sql);
while (rs.next()) {
User user = new User();
user.setUserId(rs.getString("user_id"));
user.setUserName(rs.getString("user_name"));
user.setPassword(rs.getString("password"));
user.setContactTel(rs.getString("contact_tel"));
user.setEmail(rs.getString("email"));
user.setCreateDate(rs.getTimestamp("create_date"));
userList.add(user);
}
}catch(SQLException e) {
e.printStackTrace();
}finally {
DB.closeRs(rs);
DB.closeStmt(stmt);
DB.closeConn(conn);
}
return userList;
}
/**
* 根据用户id查询用户
* @param userId 用户id
* @return user对象
*/
public User findUserById(String userId) {
String sql = "select * from t_user where user_id=?";
User user = null;
Connection conn = null;
PreparedStatement pstmt = null;
ResultSet rs = null;
try {
conn = DB.getConn();
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, userId);
rs = pstmt.executeQuery();
if (rs.next()) {
user = new User();
user.setUserId(rs.getString("user_id"));
user.setUserName(rs.getString("user_name"));
user.setPassword(rs.getString("password"));
user.setContactTel(rs.getString("contact_tel"));
user.setEmail(rs.getString("email"));
user.setCreateDate(rs.getTimestamp("create_date"));
}
}catch(SQLException e) {
e.printStackTrace();
}finally {
DB.closeRs(rs);
DB.closeStmt(pstmt);
DB.closeConn(conn);
}
return user;
}
/**
* 修改用户
* @param conn
* @param user user对象
*/
public void modifyUser(Connection conn, User user) {
String sql = "update t_user set user_name=?, password=?, contact_tel=?, email=? where user_id=?";
PreparedStatement pstmt = null;
try {
pstmt = conn.prepareStatement(sql);
pstmt.setString(1, user.getUserName());
pstmt.setString(2, user.getPassword());
pstmt.setString(3, user.getContactTel());
pstmt.setString(4, user.getEmail());
pstmt.setString(5, user.getUserId());
pstmt.executeUpdate();
}catch(SQLException e) {
e.printStackTrace();
}finally {
DB.closeStmt(pstmt);
}
}
}
UserDaoFactory.java
package com.bjsxt.drp.business.usermgr.factory;
import com.bjsxt.drp.business.usermgr.dao.UserDao;
import com.bjsxt.drp.business.usermgr.dao.UserDao4MySqlImpl;
/**
* 工厂类,负责动态装载UserDao4MySqlImpl类
*/
public class UserDaoFactory {
private static UserDaoFactory instance;
private UserDao userDao;
private UserDaoFactory() {
//
//注意:可以从配置文件中动态装载UserDao4MySqlImpl实现类,便于灵活更换
//
userDao = new UserDao4MySqlImpl();
}
public static synchronized UserDaoFactory getInstance() {
if (instance == null) {
instance = new UserDaoFactory();
}
return instance;
}
/**
* 创建UserDao对象
* @return UserDao UserDao接口
*/
public UserDao createUserDao() {
return userDao;
}
}
UserActionForm.java
package com.bjsxt.drp.web.usermgr.forms;
import java.util.Date;
import org.apache.struts.action.ActionForm;
/**
* 用户管理ActionForm
*
*/
public class UserActionForm extends ActionForm {
//用户代码
private String userId;
//用户名称
private String userName;
//密码
private String password;
//联系电话
private String contactTel;
//email
private String email;
//创建日期
private Date createDate;
//接收界面中的选中标记的集合
private String[] selectFlag;
public String getContactTel() {
return contactTel;
}
public void setContactTel(String contactTel) {
this.contactTel = contactTel;
}
public Date getCreateDate() {
return createDate;
}
public void setCreateDate(Date createDate) {
this.createDate = createDate;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getUserId() {
return userId;
}
public void setUserId(String userId) {
this.userId = userId;
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String[] getSelectFlag() {
return selectFlag;
}
public void setSelectFlag(String[] selectFlag) {
this.selectFlag = selectFlag;
}
}
UserManager.java
package com.bjsxt.drp.business.usermgr.manager;
import java.sql.Connection;
import java.util.ArrayList;
import java.util.List;
import com.bjsxt.drp.business.usermgr.dao.UserDao;
import com.bjsxt.drp.business.usermgr.factory.UserDaoFactory;
import com.bjsxt.drp.business.usermgr.model.User;
import com.bjsxt.drp.business.util.DB;
/**
* 对用户完成增删改查的管理类,采用单例模式实现
* @author Administrator
*
*/
public class UserManager {
private static UserManager instance = new UserManager();
private UserDao userDao = null;
private UserManager() {
userDao = UserDaoFactory.getInstance().createUserDao();
}
public static UserManager getInstance() {
return instance;
}
/**
* 增加用户
* @param user user对象
*/
public void addUser(User user) {
Connection conn = null;
try {
conn = DB.getConn();
userDao.addUser(conn, user);
}catch(Exception e) {
e.printStackTrace();
}finally {
DB.closeConn(conn);
}
}
/**
* 根据用户代码查询
* @param userId 用户代码
* @return user对象
*/
public User findUserById(String userId) {
User user = null;
try {
user = userDao.findUserById(userId);
}catch(Exception e) {
e.printStackTrace();
}
return user;
}
/**
* 查询所有用户
* @return user对象列表
*/
public List findAllUserList() {
List userList = new ArrayList();
try {
userList = userDao.findAllUserList();
}catch(Exception e) {
e.printStackTrace();
}
return userList;
}
/**
* 根据UserId的集合进行删除
* @param userIds userId的集合
*/
public void deleteUsers(String[] userIdList) {
Connection conn = null;
try {
conn = DB.getConn();
userDao.deleteUsers(conn, userIdList);
}catch(Exception e) {
e.printStackTrace();
}finally {
DB.closeConn(conn);
}
}
/**
* 修改用户
* @param user user对象
*/
public void modifyUser(User user) {
Connection conn = null;
try {
conn = DB.getConn();
userDao.modifyUser(conn, user);
}catch(Exception e) {
e.printStackTrace();
}finally {
DB.closeConn(conn);
}
}
}
UserAction.java
package com.bjsxt.drp.web.usermgr.actions;
import java.util.Date;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.commons.beanutils.BeanUtils;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.actions.DispatchAction;
import com.bjsxt.drp.business.usermgr.manager.UserManager;
import com.bjsxt.drp.business.usermgr.model.User;
import com.bjsxt.drp.web.usermgr.forms.UserActionForm;
/**
* 用户CRUD
* @author Administrator
*
*/
public class UserAction extends DispatchAction {
@Override
protected ActionForward unspecified(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
System.out.println("-----------UserAction.unspecified()-----------");
//调用业务逻辑操作
List userList = UserManager.getInstance().findAllUserList();
request.setAttribute("userlist", userList);
return mapping.findForward("list_success");
// ActionForward af = new ActionForward();
// af.setPath("/user/usermaint.do?command=list");
// af.setRedirect(true);
// return af;
}
/**
* 用户添加
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward add(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//获取从页面表单中提交过来的值
UserActionForm uaf = (UserActionForm)form;
User user = new User();
BeanUtils.copyProperties(user, uaf);
user.setCreateDate(new Date());
//调用业务逻辑操作
UserManager.getInstance().addUser(user);
return mapping.findForward("success");
}
/**
* 用户删除
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward del(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//获取从页面表单中提交过来的值
UserActionForm uaf = (UserActionForm)form;
//取得需要删除的userId的集合
String[] userIdList = uaf.getSelectFlag();
//调用业务逻辑操作
UserManager.getInstance().deleteUsers(userIdList);
return mapping.findForward("success");
}
/**
* 根据ID查询用户
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward find(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//获取从页面表单中提交过来的值
UserActionForm uaf = (UserActionForm)form;
String userId = uaf.getUserId();
//调用业务逻辑操作
User user = UserManager.getInstance().findUserById(userId);
//将user对象从Action传递到JSP页面
request.setAttribute("user", user);
return mapping.findForward("find_success");
}
// /**
// * 查询所有用户
// * @param mapping
// * @param form
// * @param request
// * @param response
// * @return
// * @throws Exception
// */
// public ActionForward list(ActionMapping mapping, ActionForm form,
// HttpServletRequest request, HttpServletResponse response)
// throws Exception {
// //调用业务逻辑操作
// List userList = UserManager.getInstance().findAllUserList();
// request.setAttribute("userlist", userList);
//
// return mapping.findForward("list_success");
// }
/**
* 修改用户
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward modify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
//获取从页面表单中提交过来的值
UserActionForm uaf = (UserActionForm)form;
User user = new User();
BeanUtils.copyProperties(user, uaf);
user.setCreateDate(new Date());
//调用业务逻辑操作
UserManager.getInstance().modifyUser(user);
return mapping.findForward("success");
}
}
user_input.jsp
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>添加用户</title>
<link rel="stylesheet" href="../style/drp.css">
<script src="../script/client_validate.js"></script>
<script type="text/javascript">
function addUser() {
if (document.getElementById("userId").value.length <4) {
alert("用户代码不能小于4个字符!");
document.getElementById("userId").focus();
return;
}
var firstChar = document.getElementById("userId").value.charAt(0);
if (!(firstChar >= 'a' && firstChar <='z')) {
alert("用户代码首字符必须为字母");
document.getElementById("userId").focus();
return;
}
if(document.getElementById("userName").value == "") {
alert("用户名称不能为空!");
document.getElementById("userName").focus();
return;
}
if (document.getElementById("password").value.length <6) {
alert("输入的密码不能小于6位字符");
document.getElementById("password").focus();
return;
}
with (document.getElementById("userForm")) {
method = "post";
action = "usermaint.do?command=add";
submit();
}
}
function goBack() {
window.self.location ="usermaint.do"
}
function init() {
document.userForm.userId.focus();
}
</script>
</head>
<body class="body1">
<form name="userForm" target="_self" id="userForm">
<div align="center">
<table width="95%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td>
</td>
</tr>
</table>
<table width="95%" border="0" cellspacing="0" cellpadding="0"
height="25">
<tr>
<td width="522" class="p1" height="25" nowrap>
<img src="../images/mark_arrow_03.gif" width="14" height="14">
<b>系统管理>>用户维护>>添加</b>
</td>
</tr>
</table>
<hr width="97%" align="center" size=0>
<table width="95%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="22%" height="29">
<div align="right">
<font color="#FF0000">*</font>用户代码:
</div>
</td>
<td width="78%">
<input name="userId" type="text" class="text1" id="userId"
size="10" maxlength="10">
</td>
</tr>
<tr>
<td height="26">
<div align="right">
<font color="#FF0000">*</font>用户名称:
</div>
</td>
<td>
<input name="userName" type="text" class="text1" id="userName"
size="20" maxlength="20">
</td>
</tr>
<tr>
<td height="26">
<div align="right">
<font color="#FF0000">*</font>密码:
</div>
</td>
<td>
<label>
<input name="password" type="password" class="text1"
id="password" size="20" maxlength="20">
</label>
</td>
</tr>
<tr>
<td height="26">
<div align="right">
联系电话:
</div>
</td>
<td>
<input name="contactTel" type="text" class="text1"
id="contactTel" size="20" maxlength="20">
</td>
</tr>
<tr>
<td height="26">
<div align="right">
email:
</div>
</td>
<td>
<input name="email" type="text" class="text1" id="email"
size="20" maxlength="20">
</td>
</tr>
</table>
<hr width="97%" align="center" size=0>
<div align="center">
<input name="btnAdd" class="button1" type="button" id="btnAdd"
value="添加" onClick="addUser()">
<input name="btnBack" class="button1" type="button" id="btnBack"
value="返回" onclick="goBack()" />
</div>
</div>
</form>
</body>
</html>
user_modify.jsp
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>修改用户</title>
<link rel="stylesheet" href="../style/drp.css">
<script src="../script/client_validate.js"></script>
<script type="text/javascript">
function goBack() {
window.self.location ="usermaint.do"
}
function modifyUser() {
if (document.getElementById("userName").value == "") {
alert("用户名称不能为空!");
return;
}
if (document.getElementById("password").value.length < 6) {
alert("用户密码不能小于6个字符!");
return;
}
with (document.getElementById("userForm")) {
method = "post";
action = "usermaint.do?command=modify";
submit();
}
}
</script>
</head>
<body class="body1">
<form name="userForm" id="userForm">
<div align="center">
<table width="95%" border="0" cellspacing="2" cellpadding="2">
<tr>
<td>
</td>
</tr>
</table>
<table width="95%" border="0" cellspacing="0" cellpadding="0"
height="25">
<tr>
<td width="522" class="p1" height="25" nowrap>
<img src="../images/mark_arrow_03.gif" width="14" height="14">
<b>系统管理>>用户维护>>修改</b>
</td>
</tr>
</table>
<hr width="97%" align="center" size=0>
<table width="95%" border="0" cellpadding="0" cellspacing="0">
<tr>
<td width="22%" height="29">
<div align="right">
用户代码:
</div>
</td>
<td width="78%">
<input name="userId" type="text" class="text1" id="userId" value="<bean:write name="user" property="userId"/>"
size="10" maxlength="10" readonly="true">
</td>
</tr>
<tr>
<td height="26">
<div align="right">
<font color="#FF0000">*</font>用户名称:
</div>
</td>
<td>
<input name="userName" type="text" class="text1" id="userName" value="<bean:write name="user" property="userName"/>"
size="20" maxlength="20">
</td>
</tr>
<tr>
<td height="26">
<div align="right">
<font color="#FF0000">*</font>密码:
</div>
</td>
<td>
<label>
<input name="password" type="password" class="text1" value="<bean:write name="user" property="password"/>"
id="password" size="20" maxlength="20">
</label>
</td>
</tr>
<tr>
<td height="26">
<div align="right">
联系电话:
</div>
</td>
<td>
<input name="contactTel" type="text" class="text1" value="<bean:write name="user" property="contactTel"/>"
id="contactTel" size="20" maxlength="20">
</td>
</tr>
<tr>
<td height="26">
<div align="right">
email:
</div>
</td>
<td>
<input name="email" type="text" class="text1" id="email" value="<bean:write name="user" property="email"/>"
size="20" maxlength="20">
</td>
</tr>
</table>
<hr width="97%" align="center" size=0>
<div align="center">
<input name="btnModify" class="button1" type="button"
id="btnModify" value="修改" onclick="modifyUser()">
<input name="btnBack" class="button1" type="button" id="btnBack"
value="返回" onclick="goBack()" />
</div>
</div>
</form>
</body>
</html>
user_list.jsp
<%@ page language="java" contentType="text/html; charset=GB18030"
pageEncoding="GB18030"%>
<%@ taglib prefix="bean" uri="http://struts.apache.org/tags-bean" %>
<%@ taglib prefix="logic" uri="http://struts.apache.org/tags-logic" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=GB18030">
<title>用户维护</title>
<link rel="stylesheet" href="../style/drp.css">
<script type="text/javascript">
function addUser() {
window.self.location = "user_input.jsp";
}
function modifyUser() {
var count = 0;
var j = 0;
for (var i = 0; i < document.getElementsByName("selectFlag").length; i++) {
if (document.getElementsByName("selectFlag")[i].checked) {
j = i;
count++;
}
}
if (count == 0) {
alert("请选择需要修改的用户!");
return;
}
if (count > 1) {
alert("一次只能修改一个用户!");
return;
}
if (count == 1) {
window.self.location = "usermaint.do?command=find&userId=" + document.getElementsByName("selectFlag")[j].value;
}
}
function deleteUser() {
var flag = false;
for (var i = 0; i < document.getElementsByName("selectFlag").length; i++) {
if (document.getElementsByName("selectFlag")[i].checked) {
flag = true;
}
}
if (!flag) {
alert("请选择需要删除的用户!");
return;
}
if (window.confirm("确认删除吗?")) {
with (document.getElementById("userForm")) {
method = "post";
action = "usermaint.do?command=del";
submit();
}
}
}
function checkAll() {
for (var i = 0; i < document.getElementsByName("selectFlag").length; i++) {
document.getElementsByName("selectFlag")[i].checked = document.getElementById("ifAll").checked;
}
}
</script>
</head>
<body class="body1">
<form name="userform" id="userform">
<div align="center">
<table width="95%" border="0" cellspacing="0" cellpadding="0"
height="35">
<tr>
<td class="p1" height="18" nowrap>
</td>
</tr>
<tr>
<td width="522" class="p1" height="17" nowrap>
<img src="../images/mark_arrow_02.gif" width="14" height="14">
<b>系统管理>>用户维护</b>
</td>
</tr>
</table>
<hr width="100%" align="center" size=0>
</div>
<table width="95%" height="20" border="0" align="center"
cellspacing="0" class="rd1" id="toolbar">
<tr>
<td width="49%" class="rd19">
<font color="#FFFFFF">查询列表</font>
</td>
<td width="27%" nowrap class="rd16">
<div align="right"></div>
</td>
</tr>
</table>
<table width="95%" border="1" cellspacing="0" cellpadding="0"
align="center" class="table1">
<tr>
<td width="55" class="rd6">
<input type="checkbox" name="ifAll" onClick="checkAll()">
</td>
<td width="119" class="rd6">
用户代码
</td>
<td width="152" class="rd6">
用户名称
</td>
<td width="166" class="rd6">
联系电话
</td>
<td width="150" class="rd6">
email
</td>
<td width="153" class="rd6">
创建日期
</td>
</tr>
<logic:empty name="userlist">
<tr>
<td class="rd8" colspan="6">
<font color="red">没有符合条件的数据</font>
</td>
</tr>
</logic:empty>
<logic:notEmpty name="userlist">
<logic:iterate id="user" name="userlist">
<tr>
<td class="rd8">
<input type="checkbox" name="selectFlag" class="checkbox1"
value="<bean:write name="user" property="userId"/>">
</td>
<td class="rd8">
<bean:write name="user" property="userId" />
</td>
<td class="rd8">
<bean:write name="user" property="userName" />
</td>
<td class="rd8">
<bean:write name="user" property="contactTel" />
</td>
<td class="rd8">
<bean:write name="user" property="email" />
</td>
<td class="rd8">
<bean:write name="user" property="createDate" format="yyyy-MM-dd HH:mm:ss" />
</td>
</tr>
</logic:iterate>
</logic:notEmpty>
</table>
<table width="95%" height="30" border="0" align="center"
cellpadding="0" cellspacing="0" class="rd1">
<tr>
<td nowrap class="rd19" height="2">
<div align="left">
<font color="#FFFFFF"> 共 xx 页</font>
<font color="#FFFFFF">当前第</font> 
<font color="#FF0000">x</font> 
<font color="#FFFFFF">页</font>
</div>
</td>
<td nowrap class="rd19">
<div align="right">
<input name="btnAdd" type="button" class="button1" id="btnAdd"
value="添加" onClick="addUser()">
<input name="btnDelete" class="button1" type="button"
id="btnDelete" value="删除" onClick="deleteUser()">
<input name="btnModify" class="button1" type="button"
id="btnModify" value="修改" onClick="modifyUser()">
</div>
</td>
</tr>
</table>
<p>
</p>
</form>
</body>
</html>