标签:
Web应用——驾培管理系统之系统—用户管理(作者:小圣)
本节展示本次Web应用的系统管理下的用户管理功能。
笔者会把大概实现过程贴出来,有看不懂过程且需要项目源码的请戳:http://download.csdn.net/detail/xie_xiansheng/9486872,需要数据库表格的请留言。有些小细节没完善,有些代码冗余,初学请见谅!
结果演示:
数据库的t_user表
代码对应的UserBean:
public class UserBean { private int user_id; private int role_id; private int driving_id; private String user_lname; private String user_pwd; private String user_name; private String user_sex; private String user_status; private String createtime; private String tel; private String driving_name; public String getDriving_name() { return driving_name; } public void setDriving_name(String drivingName) { driving_name = drivingName; } public int getUser_id() { return user_id; } public void setUser_id(int userId) { user_id = userId; } public int getRole_id() { return role_id; } public void setRole_id(int roleId) { role_id = roleId; } public String getUser_lname() { return user_lname; } public void setUser_lname(String userLname) { user_lname = userLname; } public String getUser_pwd() { return user_pwd; } public void setUser_pwd(String userPwd) { user_pwd = userPwd; } public String getUser_name() { return user_name; } public void setUser_name(String userName) { user_name = userName; } public String getUser_sex() { return user_sex; } public void setUser_sex(String userSex) { user_sex = userSex; } public String getUser_status() { return user_status; } public void setUser_status(String userStatus) { user_status = userStatus; } public String getCreatetime() { return createtime; } public void setCreatetime(String createtime) { this.createtime = createtime; } public int getDriving_id() { return driving_id; } public void setDriving_id(int drivingId) { driving_id = drivingId; } public String getTel() { return tel; } public void setTel(String tel) { this.tel = tel; } }
public class UserServlet extends HttpServlet{ @Override protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { req.setCharacterEncoding("utf-8"); resp.setContentType("text/html;charset=utf-8"); String task = req.getParameter("task"); HttpSession session = req.getSession(); //从登陆的传的session获取到用户信息 UserBean userBean = (UserBean)session.getAttribute("Logindo"); UserDao userDao = DaoFactory.getUserDao(); PrintWriter writer = resp.getWriter(); if("logout".equals(task)){ session = req.getSession(); session.invalidate(); req.getRequestDispatcher("index.jsp").forward(req, resp); }else if("usermanager".equals(task)){ //usermanager.jsp ->上下首尾页 //跳转到用户管理页面 PageBean pageBean = null; List<UserBean> userBeans = null; if(userBean.getRole_id()==1){//如果是超管登录,可以查看全部用户的信息 int pagenum = Integer.parseInt(req.getParameter("pagenum")); int count = userDao.countUser(); pageBean = new PageBean(); //找出count、pagenum、totalpage、pagesize、beg、end信息 pageBean.findPageBean(count, pagenum); userBeans =userDao.findPage(pageBean); //按分页查询出数据 }else{<span style="white-space:pre"> </span>//如果是驾管登陆,只能查看自己驾校的驾校管理、学员,和教练信息 int pagenum = Integer.parseInt(req.getParameter("pagenum")); int count = userDao.countUser_ByDrivId(userBean.getDriving_id()); pageBean = new PageBean(); pageBean.findPageBean(count, pagenum); userBeans =userDao.findPage_ByDriv(pageBean, userBean.getDriving_id()); <pre name="code" class="java" style="line-height: 25.98958396911621px;">//按分页查询出数据}session.setAttribute("pageBean", pageBean);req.setAttribute("userBeans", userBeans);req.getRequestDispatcher("jsp/sysmanager/usermanager.jsp").forward(req, resp);}else if("aleruser".equals(task)){//usermanager.jsp -> 跳修改jsp//页面修改操作String lname = req.getParameter("lname");userBean = userDao.findUser_ByLname(lname);req.setAttribute("userBean", userBean);req.getRequestDispatcher("jsp/sysmanager/alertuser.jsp").forward(req, resp);}else if("alertfinish".equals(task)){//alertuser.jsp -> //页面修改逻辑,完成后返回标志String alertname = req.getParameter("username");String alertsex = req.getParameter("usex");String alertstatus = req.getParameter("ustatus");int alertuserid = Integer.parseInt(req.getParameter("userid"));String msg = userDao.alertUser_ById(alertuserid, alertname, alertsex, alertstatus);userBean = userDao.findUser_ById(alertuserid);req.setAttribute("userBean", userBean);req.setAttribute("msg", "修改成功!");req.getRequestDispatcher("jsp/sysmanager/alertuser.jsp").forward(req, resp);}else if("selectuser".equals(task)){//页面查询操作 //TODOint selectUserId = Integer.parseInt(req.getParameter("userid"));userBean = userDao.findUser_ById(selectUserId);req.setAttribute("userBean", userBean);//跳转到用户查询页面req.getRequestDispatcher("jsp/sysmanager/selectuser.jsp").forward(req, resp);}else if("deleteuser".equals(task)){//用户删除操作int selectUserId = Integer.parseInt(req.getParameter("userid"));String msg = DaoFactory.getUserDao().updateUser_ById(selectUserId);int pagenum = 1;int count = userDao.countUser();PageBean pageBean = new PageBean();//找出count、pagenum、totalpage、pagesize、beg、end信息pageBean.findPageBean(count, pagenum);List<UserBean> userBeans =userDao.findPage(pageBean);session.setAttribute("pageBean", pageBean);req.setAttribute("msg", msg);req.setAttribute("userBeans", userBeans);req.getRequestDispatcher("jsp/sysmanager/usermanager.jsp").forward(req, resp);}}} PageBean.class,传入总的数据数,和页数,可以获取分页查询所需数据
package org.great.bean; import java.util.List; public class PageBean { int pagenum = 1; int count = 0; int totalpage; int pageSize = 5; int beg = 0; int end = 0; //根据传入的总的条数和第几页,可以得到总页数,每页的开始条数和结束条数,获取出这些数据可以在页面分页查看数据 public void findPageBean(int count,int pagenum){ this.count = count; this.pagenum = pagenum; totalpage = (count%pageSize==0) ? (count/pageSize):(count/pageSize)+1; beg = ((pagenum-1)*pageSize)+1; end = beg+pageSize-1; } public int getPagenum() { return pagenum; } public void setPagenum(int pagenum) { this.pagenum = pagenum; } public int getCount() { return count; } public void setCount(int count) { this.count = count; } public int getTotalpage() { return totalpage; } public void setTotalpage(int totalpage) { this.totalpage = totalpage; } public int getPageSize() { return pageSize; } public void setPageSize(int pageSize) { this.pageSize = pageSize; } public int getBeg() { return beg; } public void setBeg(int beg) { this.beg = beg; } public int getEnd() { return end; } public void setEnd(int end) { this.end = end; } }
package org.great.daoimpl; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; import java.util.ArrayList; import java.util.List; import org.great.bean.CoachBean; import org.great.bean.PageBean; import org.great.bean.StudentBean; import org.great.bean.UserBean; import org.great.dao.UserDao; import org.great.util.DBUtils; public class UserDaoImpl implements UserDao{ private PreparedStatement pre = null; private ResultSet rs = null; public UserBean findUser_ByLname(String lname) { Connection conn = DBUtils.getConn(); UserBean userBean = null; String sql = "select user_id,role_id,user_lname,user_pwd,user_name,user_sex,user_status," + "createtime,driving_id,tel from t_user where user_lname = ? and user_status!='D'" ; try { pre = conn.prepareStatement(sql); pre.setString(1, lname); rs = pre.executeQuery(); if(rs.next()){ userBean = new UserBean(); userBean.setUser_id(rs.getInt(1)); userBean.setRole_id(rs.getInt(2)); userBean.setUser_lname(rs.getString(3)); userBean.setUser_pwd(rs.getString(4)); userBean.setUser_name(rs.getString(5)); userBean.setUser_sex(rs.getString(6)); userBean.setUser_status(rs.getString(7)); userBean.setCreatetime(rs.getString(8)); userBean.setDriving_id(rs.getInt(9)); userBean.setTel(rs.getString(10)); } } catch (SQLException e) { e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } return userBean; } public List<UserBean> findUser_All() { Connection conn = DBUtils.getConn(); UserBean userBean = new UserBean(); List<UserBean> userBeans = new ArrayList<UserBean>(); String sql = "select user_id,role_id,user_lname,user_pwd,user_name,user_sex,user_status," + "createtime from t_user where user_status != 'D'"; try { pre = conn.prepareStatement(sql); rs = pre.executeQuery(); while(rs.next()){ userBean = new UserBean(); userBean.setUser_id(rs.getInt(1)); userBean.setRole_id(rs.getInt(2)); userBean.setUser_lname(rs.getString(3)); userBean.setUser_pwd(rs.getString(4)); userBean.setUser_name(rs.getString(5)); userBean.setUser_sex(rs.getString(6)); userBean.setUser_status(rs.getString(7)); userBean.setCreatetime(rs.getString(8)); userBeans.add(userBean); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ DBUtils.close(conn, pre, rs); } return userBeans; } public int countUser() { Connection conn = DBUtils.getConn(); int count = 0; String sql = "select count(*) from t_user where user_status!='D'" ; try { pre = conn.prepareStatement(sql); rs = pre.executeQuery(); if(rs.next()){ count = rs.getInt(1); } } catch (SQLException e) { e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } return count; } public List<UserBean> findPage(PageBean pageBean) { Connection conn = DBUtils.getConn(); UserBean userBean = new UserBean(); List<UserBean> userBeans = new ArrayList<UserBean>(); String sql = "select t2.* from("+ "select t1.*,rownum rn from("+ "select user_id,role_id,user_lname,user_pwd,user_name,user_sex,user_status,"+ "createtime from t_user where user_status!='D' order by createtime desc"+ ")t1"+ ")t2 where t2.rn between ? and ? "; try { pre = conn.prepareStatement(sql); pre.setInt(1, pageBean.getBeg()); pre.setInt(2, pageBean.getEnd()); rs = pre.executeQuery(); while(rs.next()){ userBean = new UserBean(); userBean.setUser_id(rs.getInt(1)); userBean.setRole_id(rs.getInt(2)); userBean.setUser_lname(rs.getString(3)); userBean.setUser_pwd(rs.getString(4)); userBean.setUser_name(rs.getString(5)); userBean.setUser_sex(rs.getString(6)); userBean.setUser_status(rs.getString(7)); userBean.setCreatetime(rs.getString(8)); userBeans.add(userBean); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ DBUtils.close(conn, pre, rs); } return userBeans; } public String alertUser_ById(int userID,String username,String usersex,String userstatus) { //TODO Connection conn = DBUtils.getConn(); String msg = ""; String sql = "update t_user set user_name = ?,user_sex = ?,user_status = ? where user_id = ?" ; try { pre = conn.prepareStatement(sql); pre.setString(1, username); pre.setString(2, usersex); pre.setString(3, userstatus); pre.setInt(4, userID); rs = pre.executeQuery(); if(rs.next()){ msg = "修改完成!"; } } catch (SQLException e) { e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } return msg; } public UserBean findUser_ById(int userID) { Connection conn = DBUtils.getConn(); UserBean userBean = null; String sql = "select u.user_id,u.role_id,u.user_lname,u.user_pwd,u.user_name,u.user_sex,u.user_status,"+ "u.createtime,u.tel,d.driving_name from t_user u,t_drivingschool d where "+ "u.driving_id = d.driving_id and user_id = ? and user_status!='D'" ; try { pre = conn.prepareStatement(sql); pre.setInt(1, userID); rs = pre.executeQuery(); if(rs.next()){ userBean = new UserBean(); userBean.setUser_id(rs.getInt(1)); userBean.setRole_id(rs.getInt(2)); userBean.setUser_lname(rs.getString(3)); userBean.setUser_pwd(rs.getString(4)); userBean.setUser_name(rs.getString(5)); userBean.setUser_sex(rs.getString(6)); userBean.setUser_status(rs.getString(7)); userBean.setCreatetime(rs.getString(8)); userBean.setTel(rs.getString(9)); userBean.setDriving_name(rs.getString(10)); } } catch (SQLException e) { e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } return userBean; } public String alertInfo_ById(int userID, String username, String usersex, String tel) { Connection conn = DBUtils.getConn(); String msg = ""; String sql = "update t_user set user_name = ?,user_sex = ?,tel = ? where user_id = ?" ; try { pre = conn.prepareStatement(sql); pre.setString(1, username); pre.setString(2, usersex); pre.setString(3, tel); pre.setInt(4, userID); rs = pre.executeQuery(); if(rs.next()){ msg = "修改完成!"; } } catch (SQLException e) { e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } return msg; } public String alertPwd_ById(int userID,String newPwd) { Connection conn = DBUtils.getConn(); String msg = ""; String sql = "update t_user set user_pwd = ? where user_id = ?" ; try { pre = conn.prepareStatement(sql); pre.setString(1, newPwd); pre.setInt(2, userID); rs = pre.executeQuery(); if(rs.next()){ msg = "修改完成!"; } } catch (SQLException e) { e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } return msg; } public void addUser_ByDriv(String lname,String name,String sex, String createTime,int Id,String tel) { Connection conn = DBUtils.getConn(); String sql ="INSERT INTO t_user VALUES (user_seq.nextval, 2, ?, '123456', ?," + " ?, 'C', ?,?,?)"; try { pre = conn.prepareStatement(sql); pre.setString(1, lname); pre.setString(2, name); pre.setString(3, sex); pre.setString(4, createTime); pre.setInt(5, Id); pre.setString(6, tel); rs = pre.executeQuery(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } } public String updateUser_ById(int userID) { Connection conn = DBUtils.getConn(); String msg = ""; String sql = "update t_user set user_status = 'D' where user_id = ?" ; try { pre = conn.prepareStatement(sql); pre.setInt(1, userID); rs = pre.executeQuery(); if(rs.next()){ msg = "删除完毕!"; } } catch (SQLException e) { e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } return msg; } public void addStu_ByNew(StudentBean studentBean) { Connection conn = DBUtils.getConn(); String sql ="INSERT INTO t_user VALUES (user_seq.nextval, 4, ?, '123456', ?," + " ?, 'C', ?,?,?)"; try { pre = conn.prepareStatement(sql); pre.setString(1, studentBean.getStu_lname()); pre.setString(2, studentBean.getStu_name()); pre.setString(3, studentBean.getStu_sex()); pre.setString(4, studentBean.getStu_create_time()); pre.setInt(5, studentBean.getDriving_id()); pre.setString(6, studentBean.getStu_tel()); rs = pre.executeQuery(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } } public void addCoach_ByNew(CoachBean coachBean) { Connection conn = DBUtils.getConn(); String sql ="INSERT INTO t_user VALUES (user_seq.nextval, 3, ?, '', ?," + " ?, 'C', ?,?,?)"; try { pre = conn.prepareStatement(sql); pre.setString(1, coachBean.getCoach_lname()); pre.setString(2, coachBean.getCoach_name()); pre.setString(3, coachBean.getCoach_sex()); pre.setString(4, coachBean.getCoach_createtime()); pre.setInt(5, coachBean.getDriving_id()); pre.setString(6, coachBean.getCoach_tel()); rs = pre.executeQuery(); } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } } public int countUser_ByDrivId(int Driving_id) { Connection conn = DBUtils.getConn(); int count = 0; String sql = "select count(*) from t_user where user_status!='D' and driving_id=?" ; try { pre = conn.prepareStatement(sql); pre.setInt(1,Driving_id); rs = pre.executeQuery(); if(rs.next()){ count = rs.getInt(1); } } catch (SQLException e) { e.printStackTrace(); } finally{ DBUtils.close(conn, pre, rs); } return count; } public List<UserBean> findPage_ByDriv(PageBean pageBean,int Driving_id) { Connection conn = DBUtils.getConn(); UserBean userBean = new UserBean(); List<UserBean> userBeans = new ArrayList<UserBean>(); String sql = "select t2.* from("+ "select t1.*,rownum rn from("+ "select user_id,role_id,user_lname,user_pwd,user_name,user_sex,user_status,"+ "createtime from t_user where user_status!='D' and driving_id = ? order by createtime desc"+ ")t1"+ ")t2 where t2.rn between ? and ? "; try { pre = conn.prepareStatement(sql); pre.setInt(1, Driving_id); pre.setInt(2, pageBean.getBeg()); pre.setInt(3, pageBean.getEnd()); rs = pre.executeQuery(); while(rs.next()){ userBean = new UserBean(); userBean.setUser_id(rs.getInt(1)); userBean.setRole_id(rs.getInt(2)); userBean.setUser_lname(rs.getString(3)); userBean.setUser_pwd(rs.getString(4)); userBean.setUser_name(rs.getString(5)); userBean.setUser_sex(rs.getString(6)); userBean.setUser_status(rs.getString(7)); userBean.setCreatetime(rs.getString(8)); userBeans.add(userBean); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); }finally{ DBUtils.close(conn, pre, rs); } return userBeans; } public String judgeLname_OnlyOne(String lname) { Connection conn = DBUtils.getConn(); String msg = ""; String sql="select user_lname from t_user where user_lname = ?"; try { pre = conn.prepareStatement(sql); pre.setString(1, lname); rs = pre.executeQuery(); if(rs.next()){ msg = lname; }else{ msg = "null"; } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return msg; } public String findUser_NameById(int userId) { Connection conn = DBUtils.getConn(); String user_name = ""; String sql = "select user_name from t_user where user_id = ? and user_status !='D'"; try { pre = conn.prepareStatement(sql); pre.setInt(1, userId); rs = pre.executeQuery(); if(rs.next()){ user_name = rs.getString(1); } } catch (SQLException e) { // TODO Auto-generated catch block e.printStackTrace(); } return user_name; } }
<%@ page language="java" import="java.util.*,org.great.bean.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'usermanager.jsp' starting page</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="styles.css"> --> <link rel="stylesheet" type="text/css" href="<%=basePath%>/background/Style/skin.css" /> <script type="text/javascript" src="../../jquery-2.1.4/jquery1.9.0.min.js"></script></head> <body> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <!-- 头部开始 --> <tr> <td width="17" valign="top" background="<%=basePath%>/background/Images/mail_left_bg.gif"> <img src="<%=basePath%>/background/Images/left_top_right.gif" width="17" height="29" /> </td> <td valign="top" background="<%=basePath%>/background/Images/content_bg.gif"> <table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" background="<%=basePath%>/background/<%=basePath%>/background/Images/content_bg.gif"> <tr><td height="31"><div class="title" style="color: red">用户管理</div></td></tr> </table> </td> <td width="16" valign="top" background="<%=basePath%>/background/Images/mail_right_bg.gif"><img src="<%=basePath%>/background/Images/nav_right_bg.gif" width="16" height="29" /></td> </tr> <!-- 中间部分开始 --> <tr> <!--第一行左边框--> <td valign="middle" background="<%=basePath%>/background/Images/mail_left_bg.gif"> </td> <!--第一行中间内容--> <td valign="top" bgcolor="#F7F8F9"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <!-- 空白行--> <tr><td colspan="2" valign="top"> </td><td> </td><td valign="top"> </td></tr> <tr> <td colspan="4"> <table> <tr> <td width="100" align="center"><img src="<%=basePath%>/background/Images/mime.gif" /></td> <td valign="bottom"><h3 style="letter-spacing:1px;color: blue">在这里,您可以查看用户信息</h3></td> </tr> </table> </td> </tr> <!-- 一条线 --> <tr> <td height="40" colspan="4"> <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"> <tr><td></td></tr> </table> </td> </tr> <!-- 产品列表开始 --> <%List<UserBean> userBeans =(List<UserBean>)request.getAttribute("userBeans"); PageBean pageBean = (PageBean)session.getAttribute("pageBean"); %> <tr> <td width="2%"> </td> <td width="96%"> <table width="100%"> <tr> <td colspan="2"> <form action="" method="post"> <table width="100%" class="cont tr_color"> <tr> <th>序号</th> <th>账户</th> <th>用户名</th> <th>性别</th> <th>账户状态</th> <th>注册时间</th> <th>操作</th> </tr> <%for(int i =0;i<userBeans.size();i++){ UserBean userBean= userBeans.get(i); %> <tr align="center" class="d"> <td><%=i+1 %></td> <td><%=userBean.getUser_lname() %></td> <td><%=userBean.getUser_name() %></td> <td><%=userBean.getUser_sex().equals("M")?"男":"女" %></td> <td><%=userBean.getUser_status().equals("C")?"在用":"锁定" %></td> <td><%=userBean.getCreatetime() %></td> <td> <a href="user.do?task=selectuser&userid=<%=userBean.getUser_id() %>"style="color: blue">查询</a> <a href="user.do?task=aleruser&lname=<%=userBean.getUser_lname() %>"style="color: blue">修改 </a> <a href="user.do?task=deleteuser&userid=<%=userBean.getUser_id() %>"style="color: blue">删除</a> </td> </tr> <%} %> <tr align="center" class="d"> <td colspan="8">共<%=pageBean.getCount() %>条数据 当前<%=pageBean.getPagenum() %>页/共<%=pageBean.getTotalpage() %>页 <a style="color: blue" href="user.do?task=usermanager&pagenum=1">首页 </a> <%if(pageBean.getPagenum()-1>0){%> <a style="color: blue" href="user.do?task=usermanager&pagenum=<%=pageBean.getPagenum()-1 %>">上一页 </a> <%}else{ %> <span style="color: red">上一页</span> <%} %> <%if(pageBean.getPagenum()+1<=pageBean.getTotalpage()){%> <a style="color: blue" href="user.do?task=usermanager&pagenum=<%=pageBean.getPagenum()+1 %>">下一页</a> <%}else{ %> <span style="color: red">下一页</span> <%} %> <a style="color: blue" href="user.do?task=usermanager&pagenum=<%=pageBean.getTotalpage()%>">尾页</a> </td> </tr> </table> </form> </td> </tr> </table> </td> <td width="2%"> </td> </tr> <!-- 产品列表结束 --> <tr> <td height="40" colspan="4"> <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"> <tr><td></td></tr> </table> </td> </tr> <tr> <td width="2%"> </td> <td width="51%" class="left_txt"> <img src="<%=basePath%>/background/Images/icon_mail.gif" width="16" height="11"> 客户服务邮箱:870873201@qq.com<br /> <img src="<%=basePath%>/background/Images/icon_phone.gif" width="17" height="14"> 官方网站:<a href="http://my.csdn.net/xie_xiansheng" target="_blank">作者博客</a> </td> <td> </td><td> </td> </tr> </table> </td> <td background="<%=basePath%>/background/Images/mail_right_bg.gif"> </td> </tr> <!-- 底部部分 --> <tr> <td valign="bottom" background="<%=basePath%>/background/Images/mail_left_bg.gif"> <img src="<%=basePath%>/background/Images/buttom_left.gif" width="17" height="17" /> </td> <td background="<%=basePath%>/background/Images/buttom_bgs.gif"> <img src="<%=basePath%>/background/Images/buttom_bgs.gif" width="17" height="17"> </td> <td valign="bottom" background="<%=basePath%>/background/Images/mail_right_bg.gif"> <img src="<%=basePath%>/background/Images/buttom_right.gif" width="16" height="17" /> </td> </tr> </table> </body> <script type="text/javascript"> var msg = "<%=request.getAttribute("msg")%>"; if("null"!=msg){ alert(msg); } </script> </html>
<%@ page language="java" import="java.util.*,org.great.bean.*" pageEncoding="utf-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'selectuser.jsp' starting page</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="styles.css"> --> <link rel="stylesheet" type="text/css" href="<%=basePath%>/background/Style/skin.css" /> </head> <body> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <!-- 头部开始 --> <tr> <td width="17" valign="top" background="<%=basePath%>/background/Images/mail_left_bg.gif"> <img src="<%=basePath%>/background/Images/left_top_right.gif" width="17" height="29" /> </td> <td valign="top" background="<%=basePath%>/background/Images/content_bg.gif"> <table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" background="<%=basePath%>/background/<%=basePath%>/background/Images/content_bg.gif"> <tr><td height="31"><div class="title" style="color: red">用户查询</div></td></tr> </table> </td> <td width="16" valign="top" background="<%=basePath%>/background/Images/mail_right_bg.gif"><img src="<%=basePath%>/background/Images/nav_right_bg.gif" width="16" height="29" /></td> </tr> <!-- 中间部分开始 --> <tr> <!--第一行左边框--> <td valign="middle" background="<%=basePath%>/background/Images/mail_left_bg.gif"> </td> <!--第一行中间内容--> <td valign="top" bgcolor="#F7F8F9"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <!-- 空白行--> <tr><td colspan="2" valign="top"> </td><td> </td><td valign="top"> </td></tr> <tr> <td colspan="4"> <table> <tr> <td width="100" align="center"><img src="<%=basePath%>/background/Images/mime.gif" /></td> <td valign="bottom"><h3 style="letter-spacing:1px;color: blue">在这里,您可以查询某位用户的信息</h3></td> </tr> </table> </td> </tr> <!-- 一条线 --> <tr> <td height="40" colspan="4"> <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"> <tr><td></td></tr> </table> </td> </tr> <!-- 添加栏目开始 --> <%UserBean userBean = (UserBean)request.getAttribute("userBean"); %> <tr> <td width="2%"> </td> <td width="96%"> <table width="100%"> <tr> <td colspan="2"> <form action="" method=""> <table width="100%" class="cont tr_color"> <tr> <th>用户ID</th> <th>账户名</th> <th>用户名</th> <th>用户性别</th> <th>用户状态</th> <th>创建时间</th> <th>所属驾校</th> <th>联系电话</th> </tr> <tr align="center" class="d"> <td><%=userBean.getUser_id() %></td> <td><%=userBean.getUser_lname() %></td> <td><%=userBean.getUser_name() %></td> <td><%=userBean.getUser_sex().equals("M")?"男":"女" %></td> <td><%=userBean.getUser_status().equals("C")?"在用":"锁定" %></td> <td><%=userBean.getCreatetime() %></td> <td><%=userBean.getDriving_name()%></td> <td><%=userBean.getTel() %></td> </tr> </table> </form> </td> </tr> </table> </td> <td width="2%"> </td> </tr> <!-- 添加栏目结束 --> <tr> <td height="40" colspan="4"> <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"> <tr><td></td></tr> </table> </td> </tr> <tr> <td width="2%"> </td> <td width="51%" class="left_txt"> <img src="<%=basePath%>/background/Images/icon_mail.gif" width="16" height="11"> 客户服务邮箱:870873201@qq.com<br /> <img src="<%=basePath%>/background/Images/icon_phone.gif" width="17" height="14"> 官方网站:<a href="http://my.csdn.net/xie_xiansheng" target="_blank">作者博客</a> </td> <td> </td><td> </td> </tr> </table> </td> <td background="<%=basePath%>/background/Images/mail_right_bg.gif"> </td> </tr> <!-- 底部部分 --> <tr> <td valign="bottom" background="<%=basePath%>/background/Images/mail_left_bg.gif"> <img src="<%=basePath%>/background/Images/buttom_left.gif" width="17" height="17" /> </td> <td background="<%=basePath%>/background/Images/buttom_bgs.gif"> <img src="<%=basePath%>/background/Images/buttom_bgs.gif" width="17" height="17"> </td> <td valign="bottom" background="<%=basePath%>/background/Images/mail_right_bg.gif"> <img src="<%=basePath%>/background/Images/buttom_right.gif" width="16" height="17" /> </td> </tr> </table> </body> </html>
<%@ page language="java" import="java.util.*,org.great.bean.*" pageEncoding="utf-8"%> <%@page import="org.great.bean.UserBean"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <base href="<%=basePath%>"> <title>My JSP 'alertuser.jsp' starting page</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="styles.css"> --> <link rel="stylesheet" type="text/css" href="<%=basePath%>/background/Style/skin.css" /> <script type="text/javascript" src="<%=basePath%>/jquery-2.1.4/jquery1.9.0.min.js"></script> <script type="text/javascript" src="<%=basePath%>/easyvalidator2/js/validate.pack.js"> </script> <link href="<%=basePath%>/easyvalidator2/css/validate.css" rel="stylesheet" type="text/css" /> </head> <body> <table width="100%" border="0" cellpadding="0" cellspacing="0"> <!-- 头部开始 --> <tr> <td width="17" valign="top" background="<%=basePath%>/background/Images/mail_left_bg.gif"> <img src="<%=basePath%>/background/Images/left_top_right.gif" width="17" height="29" /> </td> <td valign="top" background="<%=basePath%>/background/Images/content_bg.gif"> <table width="100%" height="31" border="0" cellpadding="0" cellspacing="0" background="<%=basePath%>/background/<%=basePath%>/background/Images/content_bg.gif"> <tr><td height="31"><div class="title" style="color: red">用户修改</div></td></tr> </table> </td> <td width="16" valign="top" background="<%=basePath%>/background/Images/mail_right_bg.gif"><img src="<%=basePath%>/background/Images/nav_right_bg.gif" width="16" height="29" /></td> </tr> <!-- 中间部分开始 --> <tr> <!--第一行左边框--> <td valign="middle" background="<%=basePath%>/background/Images/mail_left_bg.gif"> </td> <!--第一行中间内容--> <td valign="top" bgcolor="#F7F8F9"> <table width="100%" border="0" align="center" cellpadding="0" cellspacing="0"> <!-- 空白行--> <tr><td colspan="2" valign="top"> </td><td> </td><td valign="top"> </td></tr> <tr> <td colspan="4"> <table> <tr> <td width="100" align="center"><img src="<%=basePath%>/background/Images/mime.gif" /></td> <td valign="bottom"><h3 style="letter-spacing:1px;color: blue">在这里,您可以修改用户信息</h3></td> </tr> </table> </td> </tr> <!-- 一条线 --> <tr> <td height="40" colspan="4"> <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"> <tr><td></td></tr> </table> </td> </tr> <!-- 添加栏目开始 --> <%UserBean userBean = (UserBean)request.getAttribute("userBean"); %> <tr> <td width="2%"> </td> <td width="96%"> <table width="100%"> <tr> <td colspan="2"> <form action="user.do?task=alertfinish" method="post"> <table width="50%" class="cont" > <tr> <td width="2%"> </td> <td>用户名:</td> <td width="80%"><input class="text" type="text" name="username" value="<%=userBean.getUser_name() %>" reg="^[\u4e00-\u9fa5]{1,6}$"/> <span name="easyTip">(只允许1-6个中文字符)</span> <input type="hidden" name="userid" value="<%=userBean.getUser_id()%>"/> </td> <td width="2%"> </td> </tr> <tr> <td width="2%"> </td> <td>性别:</td> <td width="20%"> <select id="usex" name="usex"> <option value="M">男</option> <option value="W">女</option> </select> </td> <td width="2%"> </td> </tr> <tr> <td width="2%"> </td> <td>账户状态:</td> <td width="20%"> <select id="ustatus" name="ustatus"> <option id="C" value="C">在用</option> <option id="P" value="P">锁定</option> </select> </td> <td width="2%"> </td> </tr> <tr> <td> </td> <td colspan="3"><input class="btn" type="submit" value="提交" /></td> <td> </td> </tr> </table> </form> </td> </tr> </table> </td> <td width="2%"> </td> </tr> <!-- 添加栏目结束 --> <tr> <td height="40" colspan="4"> <table width="100%" height="1" border="0" cellpadding="0" cellspacing="0" bgcolor="#CCCCCC"> <tr><td></td></tr> </table> </td> </tr> <tr> <td width="2%"> </td> <td width="51%" class="left_txt"> <img src="<%=basePath%>/background/Images/icon_mail.gif" width="16" height="11"> 客户服务邮箱:870873201@qq.com<br /> <img src="<%=basePath%>/background/Images/icon_phone.gif" width="17" height="14"> 官方网站:<a href="http://my.csdn.net/xie_xiansheng" target="_blank">作者博客</a> </td> <td> </td><td> </td> </tr> </table> </td> <td background="<%=basePath%>/background/Images/mail_right_bg.gif"> </td> </tr> <!-- 底部部分 --> <tr> <td valign="bottom" background="<%=basePath%>/background/Images/mail_left_bg.gif"> <img src="<%=basePath%>/background/Images/buttom_left.gif" width="17" height="17" /> </td> <td background="<%=basePath%>/background/Images/buttom_bgs.gif"> <img src="<%=basePath%>/background/Images/buttom_bgs.gif" width="17" height="17"> </td> <td valign="bottom" background="<%=basePath%>/background/Images/mail_right_bg.gif"> <img src="<%=basePath%>/background/Images/buttom_right.gif" width="16" height="17" /> </td> </tr> </table> </body> <script type="text/javascript"> $("#usex").val("<%=userBean.getUser_sex()%>"); $("#ustatus").val("<%=userBean.getUser_status()%>"); var msg = "<%=request.getAttribute("msg")%>"; if("null"!=msg){ alert(msg); } </script> </html>
标签:
原文地址:http://blog.csdn.net/xie_xiansheng/article/details/51131082