软件需求与分析大作业进度二
1、今日工作
1)完成了用户管理、角色管理、权限管理。
2、明日目标任务。
1)实现分页功能。
成果展示:
角色管理:
权限管理:
用户管理:
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@page import="java.sql.*" %> <%--导入java.sql包--%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta charset="UTF-8" /> <title>会员列表-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title> <meta name="renderer" content="webkit" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" /> <link rel="stylesheet" href="../../static/css/font.css" /> <link rel="stylesheet" href="../../static/css/weadmin.css" /> <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> <!--[if lt IE 9]> <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <script language="javascript"> function delL() { if (!confirm("确认要删除此用户吗?")) { window.event.returnValue = false; } } </script> <body> <div class="weadmin-nav"> <span class="layui-breadcrumb"> <a href="javascript:;">首页</a> <a href="javascript:;">管理员管理</a> <a href="javascript:;"> <cite>用户管理</cite></a> </span> <a class="layui-btn layui-btn-sm" style="margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"> <i class="layui-icon layui-icon-refresh"></i> <!-- <i class="layui-icon" style="line-height:30px">ဂ</i> --> </a> </div> <% int j=0;%> <% try { Class.forName("com.mysql.jdbc.Driver"); //驱动程序名 String url = "jdbc:mysql://localhost:3306/xuqiuzhengji?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true"; //数据库名 String username = "root"; //数据库用户名 String password = "123456"; //数据库用户密码 Connection conn = DriverManager.getConnection(url, username, password); //连接状态 String name=request.getParameter("name"); if(conn != null){ //out.print("数据库连接成功!"); //out.print("<br />"); Statement stmt = null; ResultSet rs = null; String sql = "SELECT * FROM user;"; //查询语句 stmt = conn.createStatement(); rs = stmt.executeQuery(sql); int i=0; //out.print("查询结果:"); //out.print("<br/>"); while (rs.next()){ i=i+1; } j=i; System.out.println(i+"这是i"); }else{ out.print("连接失败!"); } }catch (Exception e) { //e.printStackTrace(); out.print("数据库连接异常!"); } %> <div class="weadmin-body"> <div class="weadmin-block"> <button class="layui-btn" onclick="WeAdminShow('添加用户','./adduser.jsp',600,400)"> <i class="layui-icon layui-icon-add-circle-fine"></i>添加 </button> <span class="fr" style="line-height:40px">共有数据:<%=j %> 条</span> </div> <table class="layui-table" id="memberList"> <thead> <tr> <th>用户</th> <th>真实姓名</th> <th>身份证号</th> <th>机构全称</th> <th>邮政编码</th> <th>机构属性</th> <th>描述</th> <th>操作</th> </tr> </thead> <tbody> <% try { Class.forName("com.mysql.jdbc.Driver"); //驱动程序名 String url = "jdbc:mysql://localhost:3306/xuqiuzhengji?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true"; //数据库名 String username = "root"; //数据库用户名 String password = "123456"; //数据库用户密码 Connection conn = DriverManager.getConnection(url, username, password); //连接状态 String name=request.getParameter("name"); if(conn != null){ //out.print("数据库连接成功!"); //out.print("<br />"); Statement stmt = null; ResultSet rs = null; String sql = "SELECT * FROM user;"; //查询语句 stmt = conn.createStatement(); rs = stmt.executeQuery(sql); int intPageSize; //一页显示的记录数 int intRowCount; //记录的总数 int intPageCount; //总页数 int intPage; //待显示的页码 String strPage; //设置一页显示的记录数 intPageSize = 10; //取得待显示的页码 strPage = request.getParameter("page"); //判断strPage是否等于null,如果是,显示第一页数据 if (strPage == null) { intPage = 1; } else { //将字符串转换为整型 intPage = java.lang.Integer.parseInt(strPage); } if (intPage < 1) { intPage = 1; } //获取记录总数 rs.last(); intRowCount = rs.getRow(); //计算机总页数 intPageCount = (intRowCount + intPageSize - 1) / intPageSize; //调整待显示的页码 if (intPage > intPageCount) intPage = intPageCount; if (intPageCount > 0) { //将记录指针定位到待显示页的第一条记录上 rs.absolute((intPage - 1) * intPageSize + 1); } int i=0; while (i < intPageSize && !rs.isAfterLast()){ %> <tr data-id="1"> <td><%=rs.getString("name") %></td> <td><%=rs.getString("linkman") %></td> <td><%=rs.getString("idnum") %></td> <td><%=rs.getString("oname") %></td> <td><%=rs.getString("postalcode") %></td> <td><%=rs.getString("attribute") %></td> <td><%=rs.getString("brief") %></td> <td class="td-manage"> <a onclick="member_stop(this,'10001')" href="javascript:;" title="启用"> <i class="layui-icon layui-icon-download-circle"></i> </a> <a title="编辑" onclick="WeAdminEdit('编辑','./edit.jsp?name=<%=rs.getString("name")%>&linkman=<%=rs.getString("linkman") %>&idnum=<%=rs.getString("idnum") %>&oname=<%=rs.getString("oname") %>&postalcode=<%=rs.getString("postalcode") %>&attribute=<%=rs.getString("attribute") %>&brief=<%=rs.getString("brief") %>&id=<%=rs.getInt("id") %>', 1, 600, 400)" href="javascript:;"> <i class="layui-icon layui-icon-edit"></i> </a> <a onclick="WeAdminShow('修改密码','./password.jsp?name=<%=rs.getString("name")%>&id=<%=rs.getInt("id") %>',600,400)" title="修改密码" href="javascript:;"> <i class="layui-icon layui-icon-util"></i> </a> <a title="删除" onclick="delL(this,'要删除的id')" href="./deleteuser.jsp?id=<%=rs.getInt("id")%>"> <i class="layui-icon layui-icon-delete"></i> </a> </td> </tr> <% rs.next(); i++; } //关闭连接、释放资源 rs.close(); stmt.close(); conn.close(); %> </tbody> </table> <div class="page"> <div> <a class="prev" href="usermessage.jsp?page=<%=intPage-1%>"><<</a> <span class="current"><%=intPage%></span> <% for (int t = 1; t <= intPageCount; t++) { out.print(" <a class='num' href='usermessage.jsp?page=" + t + "'>" + t + "</a>"); } %> <a class="next" href="usermessage.jsp?page=<%=intPage+1%>">>></a> </div> </div> </div> <% }else{ out.print("连接失败!"); } }catch (Exception e) { //e.printStackTrace(); out.print("数据库连接异常!"); } %> <!--<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>--> <script src="../../lib/layui/layui.js" charset="utf-8"></script> <script src="../../static/js/eleDel.js" type="text/javascript" charset="utf-8"></script> </body> </html>
角色管理:
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@page import="java.sql.*" %> <%--导入java.sql包--%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta charset="UTF-8" /> <title>会员列表-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title> <meta name="renderer" content="webkit" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" /> <link rel="stylesheet" href="../../static/css/font.css" /> <link rel="stylesheet" href="../../static/css/weadmin.css" /> <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> <!--[if lt IE 9]> <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="weadmin-nav"> <span class="layui-breadcrumb"> <a href="javascript:;">首页</a> <a href="javascript:;">管理员管理</a> <a href="javascript:;"> <cite>角色管理</cite></a> </span> <a class="layui-btn layui-btn-sm" style="margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"> <i class="layui-icon layui-icon-refresh"></i> <!-- <i class="layui-icon" style="line-height:30px">ဂ</i> --> </a> </div> <% int j=0;%> <% try { Class.forName("com.mysql.jdbc.Driver"); //驱动程序名 String url = "jdbc:mysql://localhost:3306/xuqiuzhengji?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true"; //数据库名 String username = "root"; //数据库用户名 String password = "123456"; //数据库用户密码 Connection conn = DriverManager.getConnection(url, username, password); //连接状态 String name=request.getParameter("name"); if(conn != null){ //out.print("数据库连接成功!"); //out.print("<br />"); Statement stmt = null; ResultSet rs = null; String sql = "SELECT * FROM user;"; //查询语句 stmt = conn.createStatement(); rs = stmt.executeQuery(sql); int i=0; //out.print("查询结果:"); //out.print("<br/>"); while (rs.next()){ i=i+1; } j=i; System.out.println(i+"这是i"); }else{ out.print("连接失败!"); } }catch (Exception e) { //e.printStackTrace(); out.print("数据库连接异常!"); } %> <div class="weadmin-body"> <div class="weadmin-block"> <span class="fr" style="line-height:40px">共有数据:<%=j %> 条</span> </div> <table class="layui-table" id="memberList"> <thead> <tr> <th>用户名</th> <th>角色</th> <th>操作</th> </tr> </thead> <tbody> <% try { Class.forName("com.mysql.jdbc.Driver"); //驱动程序名 String url = "jdbc:mysql://localhost:3306/xuqiuzhengji?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true"; //数据库名 String username = "root"; //数据库用户名 String password = "123456"; //数据库用户密码 Connection conn = DriverManager.getConnection(url, username, password); //连接状态 String name=request.getParameter("name"); if(conn != null){ //out.print("数据库连接成功!"); //out.print("<br />"); Statement stmt = null; ResultSet rs = null; String sql = "SELECT * FROM user;"; //查询语句 stmt = conn.createStatement(); rs = stmt.executeQuery(sql); String ss=""; int intPageSize; //一页显示的记录数 int intRowCount; //记录的总数 int intPageCount; //总页数 int intPage; //待显示的页码 String strPage; //设置一页显示的记录数 intPageSize = 10; //取得待显示的页码 strPage = request.getParameter("page"); //判断strPage是否等于null,如果是,显示第一页数据 if (strPage == null) { intPage = 1; } else { //将字符串转换为整型 intPage = java.lang.Integer.parseInt(strPage); } if (intPage < 1) { intPage = 1; } //获取记录总数 rs.last(); intRowCount = rs.getRow(); //计算机总页数 intPageCount = (intRowCount + intPageSize - 1) / intPageSize; //调整待显示的页码 if (intPage > intPageCount) intPage = intPageCount; if (intPageCount > 0) { //将记录指针定位到待显示页的第一条记录上 rs.absolute((intPage - 1) * intPageSize + 1); } int i=0; while (i < intPageSize && !rs.isAfterLast()){ ss=rs.getString("status"); if(ss.equals("1")){ ss="管理员"; }else if(ss.equals("3")){ ss="形式审核员"; }else if(ss.equals("5")){ ss="用户"; }else if(ss.equals("7")){ ss="部门审核员"; }else{ ss="未知角色"; } %> <tr data-id="1"> <td><%=rs.getString("name") %></td> <td><%=ss %></td> <td class="td-manage"> <a title="编辑" onclick="WeAdminEdit('编辑','./editusertype.jsp?name=<%=rs.getString("name")%>&id=<%=rs.getInt("id") %>&ss=<%=ss %>', 1, 600, 400)" href="javascript:;"> <i class="layui-icon layui-icon-edit"></i> </a> </td> </tr> <% rs.next(); i++; } //关闭连接、释放资源 rs.close(); stmt.close(); conn.close(); %> </tbody> </table> <div class="page"> <div> <a class="prev" href="usertypemessage.jsp?page=<%=intPage-1%>"><<</a> <span class="current"><%=intPage%></span> <% for (int t = 1; t <= intPageCount; t++) { out.print(" <a class='num' href='usertypemessage.jsp?page=" + t + "'>" + t + "</a>"); } %> <a class="next" href="usertypemessage.jsp?page=<%=intPage+1%>">>></a> </div> </div> </div> <% }else{ out.print("连接失败!"); } }catch (Exception e) { //e.printStackTrace(); out.print("数据库连接异常!"); } %> <!--<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>--> <script src="../../lib/layui/layui.js" charset="utf-8"></script> <script src="../../static/js/eleDel.js" type="text/javascript" charset="utf-8"></script> </body> </html>
权限管理:
<%@ page language="java" import="java.util.*" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@page import="java.sql.*" %> <%--导入java.sql包--%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta charset="UTF-8" /> <title>会员列表-WeAdmin Frame型后台管理系统-WeAdmin 1.0</title> <meta name="renderer" content="webkit" /> <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /> <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0" /> <link rel="stylesheet" href="../../static/css/font.css" /> <link rel="stylesheet" href="../../static/css/weadmin.css" /> <!-- 让IE8/9支持媒体查询,从而兼容栅格 --> <!--[if lt IE 9]> <script src="https://cdn.staticfile.org/html5shiv/r29/html5.min.js"></script> <script src="https://cdn.staticfile.org/respond.js/1.4.2/respond.min.js"></script> <![endif]--> </head> <body> <div class="weadmin-nav"> <span class="layui-breadcrumb"> <a href="javascript:;">首页</a> <a href="javascript:;">管理员管理</a> <a href="javascript:;"> <cite>角色管理</cite></a> </span> <a class="layui-btn layui-btn-sm" style="margin-top:3px;float:right" href="javascript:location.replace(location.href);" title="刷新"> <i class="layui-icon layui-icon-refresh"></i> <!-- <i class="layui-icon" style="line-height:30px">ဂ</i> --> </a> </div> <% int j=0;%> <% try { Class.forName("com.mysql.jdbc.Driver"); //驱动程序名 String url = "jdbc:mysql://localhost:3306/xuqiuzhengji?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true"; //数据库名 String username = "root"; //数据库用户名 String password = "123456"; //数据库用户密码 Connection conn = DriverManager.getConnection(url, username, password); //连接状态 String name=request.getParameter("name"); if(conn != null){ //out.print("数据库连接成功!"); //out.print("<br />"); Statement stmt = null; ResultSet rs = null; String sql = "SELECT * FROM user;"; //查询语句 stmt = conn.createStatement(); rs = stmt.executeQuery(sql); int i=0; //out.print("查询结果:"); //out.print("<br/>"); while (rs.next()){ i=i+1; } j=i; System.out.println(i+"这是i"); }else{ out.print("连接失败!"); } }catch (Exception e) { //e.printStackTrace(); out.print("数据库连接异常!"); } %> <div class="weadmin-body"> <div class="weadmin-block"> <span class="fr" style="line-height:40px">共有数据:<%=j %> 条</span> </div> <table class="layui-table" id="memberList"> <thead> <tr> <th>用户名</th> <th>角色</th> <th>操作</th> </tr> </thead> <tbody> <% try { Class.forName("com.mysql.jdbc.Driver"); //驱动程序名 String url = "jdbc:mysql://localhost:3306/xuqiuzhengji?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true"; //数据库名 String username = "root"; //数据库用户名 String password = "123456"; //数据库用户密码 Connection conn = DriverManager.getConnection(url, username, password); //连接状态 String name=request.getParameter("name"); if(conn != null){ //out.print("数据库连接成功!"); //out.print("<br />"); Statement stmt = null; ResultSet rs = null; String sql = "SELECT * FROM user;"; //查询语句 stmt = conn.createStatement(); rs = stmt.executeQuery(sql); String ss=""; int intPageSize; //一页显示的记录数 int intRowCount; //记录的总数 int intPageCount; //总页数 int intPage; //待显示的页码 String strPage; //设置一页显示的记录数 intPageSize = 10; //取得待显示的页码 strPage = request.getParameter("page"); //判断strPage是否等于null,如果是,显示第一页数据 if (strPage == null) { intPage = 1; } else { //将字符串转换为整型 intPage = java.lang.Integer.parseInt(strPage); } if (intPage < 1) { intPage = 1; } //获取记录总数 rs.last(); intRowCount = rs.getRow(); //计算机总页数 intPageCount = (intRowCount + intPageSize - 1) / intPageSize; //调整待显示的页码 if (intPage > intPageCount) intPage = intPageCount; if (intPageCount > 0) { //将记录指针定位到待显示页的第一条记录上 rs.absolute((intPage - 1) * intPageSize + 1); } int i=0; while (i < intPageSize && !rs.isAfterLast()){ ss=rs.getString("status"); if(ss.equals("1")){ ss="管理员"; }else if(ss.equals("3")){ ss="形式审核员"; }else if(ss.equals("5")){ ss="用户"; }else if(ss.equals("7")){ ss="部门审核员"; }else{ ss="未知角色"; } %> <tr data-id="1"> <td><%=rs.getString("name") %></td> <td><%=ss %></td> <td class="td-manage"> <a title="编辑" onclick="WeAdminEdit('编辑','./edituserlimit.jsp?xqzjqx=<%=rs.getString("xqzjqx")%>&llxqqx=<%=rs.getString("llxqqx") %>&grxxqx=<%=rs.getString("grxxqx") %>&tjcxqx=<%=rs.getString("tjcxqx")%>&id=<%=rs.getInt("id") %>', 1, 600, 400)" href="javascript:;"> <i class="layui-icon layui-icon-edit"></i> </a> </td> </tr> <% rs.next(); i++; } //关闭连接、释放资源 rs.close(); stmt.close(); conn.close(); %> </tbody> </table> <div class="page"> <div> <a class="prev" href="userlimitmessage.jsp?page=<%=intPage-1%>"><<</a> <span class="current"><%=intPage%></span> <% for (int t = 1; t <= intPageCount; t++) { out.print(" <a class='num' href='userlimitmessage.jsp?page=" + t + "'>" + t + "</a>"); } %> <a class="next" href="userlimitmessage.jsp?page=<%=intPage+1%>">>></a> </div> </div> </div> <% }else{ out.print("连接失败!"); } }catch (Exception e) { //e.printStackTrace(); out.print("数据库连接异常!"); } %> <!--<script type="text/javascript" src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>--> <script src="../../lib/layui/layui.js" charset="utf-8"></script> <script src="../../static/js/eleDel.js" type="text/javascript" charset="utf-8"></script> </body> </html>