目录
题目:设计一个简单的网上名片管理系统,实现名片的增、删、改、查及回收站等操作。
1.用户登录与注册模块
系统的使用者必须是注册用户,一个注册用户需要注册的信息有:用户登录名、密码、用户真实名字等信息。该模块具有两个功能:
(1)用户登录:在登录时,如果用户名和密码正确,进入系统页面。
(2)用户注册:新用户应该先注册,然后再登录该系统。
2.名片管理模块
一个名片包含信息有:序号(id)、姓名(name)、性别(sex)、电话(tel)等有关信息,需要完成对名片有关的管理操作,主要有:
(1)增加名片:增加名片信息到数据库内。
(2)修改名片:修改名片信息。
(3)查询名片:以模糊查询方式查询名片。
(4)删除名片:名片的删除由2种方式,即把名片移到回收站,把名片彻底删除。
(5)浏览/查询:可以模糊查询、浏览目前有效的名片。
3.回收站管理模块
(1)还原:把回收站中的名片还原回收。
(2)彻底删除:把名片彻底从回收站删除。
(3)浏览/查询:可以模糊查询、浏览回收站中的名片。
注:序号(id)在此名片表中具有唯一性,不可重复。
1.系统设计前准备:
(1)所用技术:HTML+JSP+MySQL+JDBC(可使用CSS和JavaScript优化美观页面)
(2)使用环境:Eclipse
(3)MySQL端口号:13306(此为自己设置的,大部分为3306)
(4)创建数据库(root01)
该数据库下有三个表,如下:
名片表(idcard),回收站表(recycle)
账号密码表(root01_01)
2.注册页面:
<!-- 登录原始页面 --> <!--A_main_A_register02.jsp--> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>已有用户登录页面</title> </head> <body> <center> <form action="A_register04.jsp" method="post"> <table> <tr><td>账号:</td><td><input type="text" name="root02" required></td></tr> <tr><td>密码:</td><td><input type="password" name="password02" required></td></tr> <tr><td colspan="2"> <input type="submit" value="登录"> <input type="reset" value="取消"></td> </tr> </table> <font color="red">没有账号?<a href="A_register01.jsp">在线注册</a></font> </form> </center> </body> </html> <!-- 登录CSS优化页面 --> <!--A_main_A_register02.jsp--> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>已有用户登录页面</title> </head> <body> <style> *{ margin: 0px;/*margin是盒子的外边距,即盒子与盒子之间的距离,而pdding是内边距,是盒子的边与盒子内部元素的距离*/ padding: 10px; box-sizing: border-box; } body{ background: pink no-repeat center; } .ra_layout{ width: 1150px; height: 550px; border: 8px solid #EEEEEE; background-color: white; margin: auto;/*让div水平居中*/ margin-top: 100px; padding: 15px; } .re_left{ /*border: 1px solid red;*/ float: left; margin: 15px; } .re_left > p:first-child{ color: #FFD026; font-size: 20px; } .re_left > p:last-child{ color: #A6A6A6; font-size: 20px; } .re_center{ float: left; margin: 60px; width: 500px; } .re_from{ padding: 25px; padding-right: 80px; } .re_right{ float: right; margin-right: 15px; padding-right: 15px; } .re_right > p:first-child{ font-size: 20px; } .re_right p a{ color: green; } .td_left{ width: 150px; text-align: right;/*右对齐*/ height: 60px;/*上下两行间隔开,出现空行效果*/ } .td_right{ padding-left: 10px;/*将文字与文本框之间出现间隔*/ } #root02,#password02{ width: 200px; height: 25px; border: 1px solid #A6A6A6; /*设置边框圆角*/ border-radius: 5px; padding-left: 10px; } #but{ width: 125px; height: 50px; background-color: #FFD026; border: 1px solid #FFD026; } </style> <div class="ra_layout"> <div class="re_left"> <p>用户登录</p> <p>USER LOGIN</p> </div> <div class="re_center"> <div class="re_from"> <form action="A_register04.jsp" method="post"> <table> <tr><td class="td_left">账号:</td><td class="td_right"><input type="text" name="root02" id="root02" required></td></tr> <tr><td class="td_left">密码:</td><td class="td_right"><input type="password" name="password02" id="password02" required></td></tr> <tr><td colspan="2" align="center"> <input type="submit" value="登录" id="but"> <input type="reset" value="取消" id="but"></td> </tr> </table> </form> </div> </div> <div class="re_right"> <p>没有账号?<a href="A_register01.jsp">在线注册</a></p> </div> </div> </body> </html>
<!-- 注册原始页面 --> <!--A_register01.jsp--> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>新用户注册页面</title> </head> <body> <center> <form action="A_register03.jsp" method="post"> <table> <tr><td>姓名:</td><td><input type="text" name="name01" required></td></tr> <tr><td>账号:</td><td><input type="text" name="root01" required></td></tr> <tr><td>密码:</td><td><input type="text" name="password01" required></td></tr> <tr><td colspan="2"> <input type="submit" value="提交"> <input type="reset" value="取消"></td> </tr> </table> </form> <font color="red">已有账号?<a href="A_main_A_register02.jsp">立即登录</a></font> </center> </body> </html> <!-- 注册CSS优化页面 --> <!--A_register01.jsp--> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>新用户注册页面</title> </head> <body> <style> *{ margin: 0px;/*margin是盒子的外边距,即盒子与盒子之间的距离,而pdding是内边距,是盒子的边与盒子内部元素的距离*/ padding: 10px; box-sizing: border-box; } body{ background: pink no-repeat center; } .ra_layout{ width: 1150px; height: 550px; border: 8px solid #EEEEEE; background-color: white; margin: auto;/*让div水平居中*/ margin-top: 100px; padding: 15px; } .re_left{ /*border: 1px solid red;*/ float: left; margin: 15px; } .re_left > p:first-child{ color: #FFD026; font-size: 20px; } .re_left > p:last-child{ color: #A6A6A6; font-size: 20px; } .re_center{ float: left; margin: 60px; width: 500px; } .re_from{ padding: 25px; padding-right: 80px; } .re_right{ float: right; margin-right: 15px; padding-right: 15px; } .re_right > p:first-child{ font-size: 20px; } .re_right p a{ color: green; } .td_left{ width: 150px; text-align: right;/*右对齐*/ height: 60px;/*上下两行间隔开,出现空行效果*/ } .td_right{ padding-left: 10px;/*将文字与文本框之间出现间隔*/ } #root01,#password01,#name01{ width: 200px; height: 25px; border: 1px solid #A6A6A6; /*设置边框圆角*/ border-radius: 5px; padding-left: 10px; } #but{ width: 125px; height: 50px; background-color: #FFD026; border: 1px solid #FFD026; } </style> <div class="ra_layout"> <div class="re_left"> <p>新用户注册</p> <p>USER REGISTER</p> </div> <div class="re_center"> <div class="re_from"> <form action="A_register03.jsp" method="post"> <table> <tr><td class="td_left">姓名:</td><td class="td_right"><input type="text" name="name01" id="name01" required></td></tr> <tr><td class="td_left">账号:</td><td class="td_right"><input type="text" name="root01" id="root01" required></td></tr> <tr><td class="td_left">密码:</td><td class="td_right"><input type="text" name="password01" id="password01" required></td></tr> <tr><td colspan="2"> <input type="submit" value="提交" id="but"> <input type="reset" value="取消" id="but"></td> </tr> </table> </form> </div> </div> <div class="re_right"> <p>已有账号?<a href="A_main_A_register02.jsp">立即登录</a></p> </div> </div> </body> </html>
<!--A_register03.jsp--> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>账号密码验证页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/";//端口号为13306 String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from root01_01 where root1=?"; PreparedStatement pst1=conn.prepareStatement(sql1); String name11=request.getParameter("name01"); String root11=request.getParameter("root01"); String password11=request.getParameter("password01"); pst1.setString(1, root11); ResultSet rs=pst1.executeQuery(); if(rs.next()) { out.println("该用户已存在,去登陆吧!"); //response.sendRedirect("A_register02.jsp");//直接跳转到登录页面 response.setHeader("refresh", "3;url=A_main_A_register02.jsp");//3秒自动刷新并跳转到登录页面 } else{ String sql2="insert into root01_01(name1,root1,password1) values(?,?,?)"; PreparedStatement pst2=conn.prepareStatement(sql2); pst2.setString(1, name11); pst2.setString(2, root11); pst2.setString(3, password11); int n=pst2.executeUpdate(); if(n!=0){ out.println("注册"+n+"条用户成功,去登陆吧!"); response.setHeader("refresh", "3;url=A_main_A_register02.jsp"); }else{ out.println("注册失败!"); } if(pst2!=null) pst2.close(); } if(rs!=null) rs.close(); if(pst1!=null) pst1.close(); if(conn!=null) conn.close(); %> </body> </html>
<!--A_register04.jsp--> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>已有用户登录验证页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/"; String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from root01_01 where root1=? and password1=?"; PreparedStatement pst1=conn.prepareStatement(sql1); String root12=request.getParameter("root02"); String password12=request.getParameter("password02"); pst1.setString(1, root12); pst1.setString(2, password12); ResultSet rs=pst1.executeQuery(); if(rs.next()) { out.println("欢迎使用!页面即将跳转!"); response.setHeader("refresh", "2;index_main.jsp");//2秒自动刷新并跳转到登录页面 }else { out.println("用户不存在或账号密码错误!"); response.setHeader("refresh", "2;A_main_A_register02.jsp"); } if(rs!=null) rs.close(); if(pst1!=null) pst1.close(); if(conn!=null) conn.close(); %> </body> </html>
3.增加页面:
<!-- insert01.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加提交页面</title> </head> <body> 请填写添加的记录:<hr width="100%" size="3"><br><br><br> <form action="insert02.jsp" method="post"> <table borrder="0" width="238" height="252"> <tr><td>学号:</td><td><input type="text" name="id03" required></td></tr> <tr><td>姓名:</td><td><input type="text" name="name03" required></td></tr> <tr><td>性别:</td><td>男<input type="radio" name="sex03" value="男" checked> 女<input type="radio" name="sex03" value="女"></td></tr> <tr><td>电话:</td><td><input type="text" name="tel03" required></td></tr> <br> <tr> <td colspan="2"> <input type="submit" value="提交"> <input type="reset" value="取消"></td></tr> </table> </form> </body> </html>
<!-- insert02.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>添加解析页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/"; String dbname="root01"; String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from idcard where id=?"; PreparedStatement pst1=conn.prepareStatement(sql1); int id13=Integer.parseInt(request.getParameter("id03")); String name13=request.getParameter("name03"); String sex13=request.getParameter("sex03"); int tel13=Integer.parseInt(request.getParameter("tel03")); pst1.setInt(1, id13); ResultSet rs=pst1.executeQuery(); if(rs.next()) { out.println("该用户ID已存在!"); if(conn!=null) conn.close(); if(pst1!=null) pst1.close(); if(rs!=null) rs.close(); response.setHeader("refresh","2;insert01.jsp"); }else { String sql2="insert into idcard(id,name,sex,tel) values(?,?,?,?)"; PreparedStatement pst2=conn.prepareStatement(sql2); pst2.setInt(1, id13); pst2.setString(2, name13); pst2.setString(3, sex13); pst2.setInt(4, tel13); int n=pst2.executeUpdate(); if(n!=0){ out.println("添加"+n+"条记录成功!"); }else{ out.println("添加失败!"); response.setHeader("refresh","2;insert02.jsp"); } if(pst2!=null) pst2.close(); if(conn!=null) conn.close(); if(pst1!=null) pst1.close(); if(rs!=null) rs.close(); out.println("是否具需添加?(yes/no)"); %> <form action="insert03.jsp"> <input type="text" name="x1"> <input type="submit" value="添加"> <input type="reset" value="重置"> </form> <%} %> </body> </html>
<!-- insert03.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>循环添加页面</title> </head> <body> <% String x=request.getParameter("x1"); if(x.equals("yes")){ response.sendRedirect("insert01.jsp"); } else if(x.equals("no")){ out.println("添加结束!"); } else { out.println("请求非法!"); } %> </body> </html>
4.删除页面:
<!-- delete01.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>删除提交页面</title> </head> <body> 请选择删除条件:<hr width="100%" size="3"><br><br><br> <form action="delete02.jsp" method="post"> <table> <tr><td>学号:</td><td><input type="text" name="id04" required></td></tr><br> <tr><td><input type="submit" value="提交"></td> <td><input type="reset" value="取消"></td></tr> </table> </form> </body> </html>
<!-- delete02.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>删除操作页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/"; String dbname="root01"; String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from idcard where id=?"; PreparedStatement pst1=conn.prepareStatement(sql1); int id44=Integer.parseInt(request.getParameter("id04")); pst1.setInt(1, id44); ResultSet rs=pst1.executeQuery(); if(rs.next()) { int id14=rs.getInt("id"); String name14=rs.getString("name"); String sex14=rs.getString("sex"); int tel14=rs.getInt("tel"); String sql2="insert into recycle(id,name,sex,tel) values(?,?,?,?)"; PreparedStatement pst2=conn.prepareStatement(sql2); pst2.setInt(1, id14); pst2.setString(2, name14); pst2.setString(3, sex14); pst2.setInt(4, tel14); int n2=pst2.executeUpdate(); if(n2!=0){ out.println("回收站添加"+n2+"条记录!"); }else{ out.println("回收站添加失败!"); } if(pst2!=null) pst2.close(); String sql3="delete from idcard where id=?"; PreparedStatement pst3=conn.prepareStatement(sql3); pst3.setInt(1, id44); int n3=pst3.executeUpdate(); if(n3!=0){ out.println("删除"+n3+"条记录!"); }else{ out.println("删除失败!"); } if(pst3!=null) pst3.close(); if(conn!=null) conn.close(); if(rs!=null) rs.close(); } else{ out.println("删除失败!"); if(conn!=null) conn.close(); if(rs!=null) rs.close(); } %> </body> </html>
5.修改页面:
<!-- update01.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>修改提交页面</title> </head> <body> 请选择修改记录满足的条件:<hr width="100%" size="3"><br><br><br> <form action="update02.jsp" method="post"> <table> <tr> <td>学号:</td><td><input type="text" name="id_up" required></td> </tr> <br> <tr> <td><input type="submit" value="提交"></td> <td><input type="reset" value="取消"></td> </tr> </table> </form> </body> </html>
<!-- update02.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>修改解析页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/";//端口号为13306 String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); int id_up=Integer.parseInt(request.getParameter("id_up")); session.setAttribute("id_up", id_up); String sql="select * from idcard where id=?"; PreparedStatement pst=conn.prepareStatement(sql); pst.setInt(1, id_up); ResultSet rs=pst.executeQuery(); if(rs.next()) {%> <form action="update03.jsp" method="post"> <table border="0" width="238" height="252"> <tr><td>学号:</td><td><input type="text" name="id1"></td></tr> <tr><td>姓名:</td><td><input type="text" name="name1"></td></tr> <tr><td>性别:</td><td>男<input type="radio" name="sex1" value="男" checked> 女<input type="radio" name="sex1" value="女"></td></tr> <tr><td>电话:</td><td><input type="text" name="tel1"></td> <tr> <td colspan="2"> <input type="submit" value="提交"> <input type="reset" value="取消"></td></tr> </table> </form> <% if(rs!=null) rs.close(); if(pst!=null) pst.close(); if(conn!=null) conn.close(); } else { out.println("未找到记录!"); if(rs!=null) rs.close(); if(pst!=null) pst.close(); if(conn!=null) conn.close(); response.setHeader("refresh", "2;url=update01.jsp"); } %> </body> </html>
<!-- update03.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>修改操作页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/";//端口号为13306 String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from idcard where id=?"; PreparedStatement pst1=conn.prepareStatement(sql1); int id2=Integer.parseInt(request.getParameter("id1")); String name2=request.getParameter("name1"); String sex2=request.getParameter("sex1"); int tel2=Integer.parseInt(request.getParameter("tel1")); int id_up=(int)session.getAttribute("id_up"); pst1.setInt(1, id2); ResultSet rs=pst1.executeQuery(); if(rs.next()) { out.println("该用户已存在,请重新填写!"); if(conn!=null) conn.close(); if(pst1!=null) pst1.close(); if(rs!=null) rs.close(); response.setHeader("refresh", "2;update01.jsp"); } else { String sql2="update idcard set id=?,name=?,sex=?,tel=? where id=?"; PreparedStatement pst2=conn.prepareStatement(sql2); pst2.setInt(1, id2); pst2.setString(2, name2); pst2.setString(3, sex2); pst2.setInt(4, tel2); pst2.setInt(5, id_up); int n=pst2.executeUpdate(); if(n!=0){ out.println("修改了"+n+"条数据!"); if(pst2!=null) pst2.close(); if(conn!=null) conn.close(); if(pst1!=null) pst1.close(); if(rs!=null) rs.close(); }else{ out.println("修改失败,请重新修改!"); if(pst2!=null) pst2.close(); if(conn!=null) conn.close(); if(pst1!=null) pst1.close(); if(rs!=null) rs.close(); } } %> </body> </html>
6.查询页面:
<!-- query01.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>查询选择页面</title> </head> <body> 请填写查询的内容:<hr width="100%" size="3"><br><br><br> <form action="query02.jsp" method="post"> <input type="radio" name="rad1" value="1" checked="checked">按学号查询 <br><br> <input type="radio" name="rad1" value="2">按姓名查询 <br><br> <input type="radio" name="rad1" value="3">按电话查询 <br><br> <input type="radio" name="rad1" value="4">查询全部人员 <br><br> <input type="submit" value="提交"> <input type="reset" value="取消"> </form> </body> </html>
<!-- query02.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>查询页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); String x=request.getParameter("rad1"); if(x.equals("1")) {%> <br><br><br> <form action="query03.jsp" method="post"> <table> <tr>请输入学号(模糊查询):</tr> <tr><input type="text" name="id07"></tr><br><br> <tr><input type="submit" value="提交"></tr> <tr><input type="reset" value="重置"></tr> </table> </form> <%} else if(x.equals("2")) {%> <br><br><br> <form action="query04.jsp" method="post"> <table> <tr>请输入姓名(模糊查询):</tr> <tr><input type="text" name="name07"></tr><br><br> <tr><input type="submit" value="提交"></tr> <tr><input type="reset" value="重置"></tr> </table> </form> <%} else if(x.equals("3")) {%> <br><br><br> <form action="query05.jsp" method="post"> <table> <tr>请输入电话(模糊查询):</tr> <tr><input type="text" name="tel07"></tr><br><br> <tr><input type="submit" value="提交"></tr> <tr><input type="reset" value="重置"></tr> </table> </form> <%} else { response.sendRedirect("query06.jsp"); } %> </body> </html>
<!-- query03.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>学号查询页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/";//端口号为13306 String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from idcard where id like '%"; String sql2=request.getParameter("id07"); String sql3="%'"; String sql=sql1+sql2+sql3; PreparedStatement pst=conn.prepareStatement(sql); ResultSet rs=pst.executeQuery(); rs.last();%> <center> <form action="#"> <table border="2" bgcolor="ccceee" width="650"> <tr bgcolor="CCCCCC" align="center"> <td>记录条数</td><td>学号</td><td>姓名</td> <td>性别</td><td>电话</td> </tr> <%rs.beforeFirst(); while(rs.next()) { %> <tr align="center"> <td><%=rs.getRow() %></td> <td><%=rs.getString("id") %></td> <td><%=rs.getString("name") %></td> <td><%=rs.getString("sex") %></td> <td><%=rs.getString("tel") %></td> </tr> <%} %> </table> </form> </center> <% if(pst!=null) pst.close(); if(conn!=null) conn.close(); if(rs!=null) rs.close(); %> </body> </html>
<!-- query04.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>姓名查询页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/";//端口号为13306 String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from idcard where name like '%"; String sql2=request.getParameter("name07"); String sql3="%'"; String sql=sql1+sql2+sql3; PreparedStatement pst=conn.prepareStatement(sql); ResultSet rs=pst.executeQuery(); rs.last();%> <center> <form action="#"> <table border="2" bgcolor="ccceee" width="650"> <tr bgcolor="CCCCCC" align="center"> <td>记录条数</td><td>学号</td><td>姓名</td> <td>性别</td><td>电话</td> </tr> <%rs.beforeFirst(); while(rs.next()) { %> <tr align="center"> <td><%=rs.getRow() %></td> <td><%=rs.getString("id") %></td> <td><%=rs.getString("name") %></td> <td><%=rs.getString("sex") %></td> <td><%=rs.getString("tel") %></td> </tr> <%} %> </table> </form> </center> <% if(pst!=null) pst.close(); if(conn!=null) conn.close(); if(rs!=null) rs.close(); %> </body> </html>
<!-- query05.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>电话查询页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/";//端口号为13306 String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from idcard where tel like '%"; String sql2=request.getParameter("tel07"); String sql3="%'"; String sql=sql1+sql2+sql3; PreparedStatement pst=conn.prepareStatement(sql); ResultSet rs=pst.executeQuery(); rs.last();%> <center> <form action="#"> <table border="2" bgcolor="ccceee" width="650"> <tr bgcolor="CCCCCC" align="center"> <td>记录条数</td><td>学号</td><td>姓名</td> <td>性别</td><td>电话</td> </tr> <%rs.beforeFirst(); while(rs.next()) { %> <tr align="center"> <td><%=rs.getRow() %></td> <td><%=rs.getString("id") %></td> <td><%=rs.getString("name") %></td> <td><%=rs.getString("sex") %></td> <td><%=rs.getString("tel") %></td> </tr> <%} %> </table> </form> </center> <% if(pst!=null) pst.close(); if(conn!=null) conn.close(); if(rs!=null) rs.close(); %> </body> </html>
<!-- query06.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>查询全部人员页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/";//端口号为13306 String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql="select * from idcard"; PreparedStatement pst=conn.prepareStatement(sql); ResultSet rs=pst.executeQuery(); rs.last();%> <center> <form action="#"> <table border="2" bgcolor="ccceee" width="650"> <tr bgcolor="CCCCCC" align="center"> <td>记录条数</td><td>学号</td><td>姓名</td> <td>性别</td><td>电话</td> </tr> <%rs.beforeFirst(); while(rs.next()) { %> <tr align="center"> <td><%=rs.getRow() %></td> <td><%=rs.getString("id") %></td> <td><%=rs.getString("name") %></td> <td><%=rs.getString("sex") %></td> <td><%=rs.getString("tel") %></td> </tr> <%} %> </table> </form> </center> <% if(pst!=null) pst.close(); if(conn!=null) conn.close(); if(rs!=null) rs.close(); %> </body> </html>
7.回收站页面:
<!-- recycle01.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>回收站页面</title> </head> <body> 请填写回收站查询的内容:<hr width="100%" size="3"><br><br><br> <form action="recycle02.jsp" method="post"> <input type="radio" name="rad2" value="1" checked="checked">按学号查询 <br><br> <input type="radio" name="rad2" value="2">按姓名查询 <br><br> <input type="radio" name="rad2" value="3">按电话查询 <br><br> <input type="radio" name="rad2" value="4">查询全部人员 <br><br> <input type="submit" value="提交"> <input type="reset" value="取消"> </form> </body> </html>
<!-- recycle02.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>回收站填写页面</title> </head> <body> 回收站页面:<hr width="100%" size="3"><br><br><br> <% request.setCharacterEncoding("UTF-8"); String x=request.getParameter("rad2"); if(x.equals("1")) {%> <br><br><br> <form action="recycle03.jsp" method="post"> <table> <tr>请输入学号(模糊查询):</tr> <tr><input type="text" name="id08"></tr><br><br> <tr><input type="submit" value="提交"></tr> <tr><input type="reset" value="重置"></tr> </table> </form> <%} else if(x.equals("2")) {%> <br><br><br> <form action="recycle04.jsp" method="post"> <table> <tr>请输入姓名(模糊查询):</tr> <tr><input type="text" name="name08"></tr><br><br> <tr><input type="submit" value="提交"></tr> <tr><input type="reset" value="重置"></tr> </table> </form> <%} else if(x.equals("3")) {%> <br><br><br> <form action="recycle05.jsp" method="post"> <table> <tr>请输入电话(模糊查询):</tr> <tr><input type="text" name="tel08"></tr><br><br> <tr><input type="submit" value="提交"></tr> <tr><input type="reset" value="重置"></tr> </table> </form> <%} else { response.sendRedirect("recycle06.jsp"); } %> </body> </html>
<!-- recycle03.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>回收站学号模糊查询</title> </head> <body> 回收站页面:<hr width="100%" size="3"><br><br><br> <script type="text/javascript"> function reduction() { location.href ="recycle10.jsp"; } function Delete() { location.href ="recycle09.jsp"; } </script> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/";//端口号为13306 String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from recycle where id like '%"; String sql2=request.getParameter("id08"); String sql3="%'"; String sql=sql1+sql2+sql3; PreparedStatement pst=conn.prepareStatement(sql); ResultSet rs=pst.executeQuery(); rs.last();%> <center> <form action="#"> <table border="2" bgcolor="ccceee" width="1000"> <tr bgcolor="CCCCCC" align="center"> <td>记录条数</td><td>学号</td><td>姓名</td> <td>性别</td><td>电话</td><td>单个删除</td><td>单个还原</td> </tr> <%rs.beforeFirst(); while(rs.next()) { %> <tr align="center"> <td><%=rs.getRow() %></td> <td><%=rs.getString("id") %></td> <td><%=rs.getString("name") %></td> <td><%=rs.getString("sex") %></td> <td><%=rs.getString("tel") %></td> <%int x=Integer.parseInt(rs.getString("id")); %> <%session.setAttribute("id18", x); %> <td><a href="recycle07.jsp">删除</a></td> <td><a href="recycle08.jsp">还原</a></td> </tr> <%} %> </table> </form> <% if(pst!=null) pst.close(); if(conn!=null) conn.close(); if(rs!=null) rs.close(); %> <br> <input type="button" name="name1" value="全部还原" onclick="reduction()"> <input type="button" name="name2" value="全部删除" onclick="Delete()"> </center> </body> </html>
<!-- recycle04.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>回收站姓名模糊查询</title> </head> <body> 回收站页面:<hr width="100%" size="3"><br><br><br> <script type="text/javascript"> function reduction() { location.href ="recycle10.jsp"; } function Delete() { location.href ="recycle09.jsp"; } </script> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/";//端口号为13306 String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from recycle where id like '%"; String sql2=request.getParameter("name08"); String sql3="%'"; String sql=sql1+sql2+sql3; PreparedStatement pst=conn.prepareStatement(sql); ResultSet rs=pst.executeQuery(); rs.last();%> <center> <form action="#"> <table border="2" bgcolor="ccceee" width="1000"> <tr bgcolor="CCCCCC" align="center"> <td>记录条数</td><td>学号</td><td>姓名</td> <td>性别</td><td>电话</td><td>单个删除</td><td>单个还原</td> </tr> <%rs.beforeFirst(); while(rs.next()) { %> <tr align="center"> <td><%=rs.getRow() %></td> <td><%=rs.getString("id") %></td> <td><%=rs.getString("name") %></td> <td><%=rs.getString("sex") %></td> <td><%=rs.getString("tel") %></td> <%int x=Integer.parseInt(rs.getString("id")); %> <%session.setAttribute("id18", x); %> <td><a href="recycle07.jsp">删除</a></td> <td><a href="recycle08.jsp">还原</a></td> </tr> <%} %> </table> </form> <% if(pst!=null) pst.close(); if(conn!=null) conn.close(); if(rs!=null) rs.close(); %> <br> <input type="button" name="name1" value="全部还原" onclick="reduction()"> <input type="button" name="name2" value="全部删除" onclick="Delete()"> </center> </body> </html>
<!-- recycle05.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>回收站电话模糊查询</title> </head> <body> 回收站页面:<hr width="100%" size="3"><br><br><br> <script type="text/javascript"> function reduction() { location.href ="recycle10.jsp"; } function Delete() { location.href ="recycle09.jsp"; } </script> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/";//端口号为13306 String dbname="root01";//密码库root01 String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from recycle where id like '%"; String sql2=request.getParameter("tel08"); String sql3="%'"; String sql=sql1+sql2+sql3; PreparedStatement pst=conn.prepareStatement(sql); ResultSet rs=pst.executeQuery(); rs.last();%> <center> <form action="#"> <table border="2" bgcolor="ccceee" width="1000"> <tr bgcolor="CCCCCC" align="center"> <td>记录条数</td><td>学号</td><td>姓名</td> <td>性别</td><td>电话</td><td>单个删除</td><td>单个还原</td> </tr> <%rs.beforeFirst(); while(rs.next()) { %> <tr align="center"> <td><%=rs.getRow() %></td> <td><%=rs.getString("id") %></td> <td><%=rs.getString("name") %></td> <td><%=rs.getString("sex") %></td> <td><%=rs.getString("tel") %></td> <%int x=Integer.parseInt(rs.getString("id")); %> <%session.setAttribute("id18", x); %> <td><a href="recycle07.jsp">删除</a></td> <td><a href="recycle08.jsp">还原</a></td> </tr> <%} %> </table> </form> <% if(pst!=null) pst.close(); if(conn!=null) conn.close(); if(rs!=null) rs.close(); %> <br> <input type="button" name="name1" value="全部还原" onclick="reduction()"> <input type="button" name="name2" value="全部删除" onclick="Delete()"> </center> </body> </html>
<!-- recycle06.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>回收站查询全部页面</title> </head> <body> 回收站页面:<hr width="100%" size="3"><br><br><br> <script type="text/javascript"> function reduction() { location.href ="recycle10.jsp"; } function Delete() { location.href ="recycle09.jsp"; } </script> <center> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/"; String dbname="root01"; String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from recycle"; PreparedStatement pst1=conn.prepareStatement(sql1); ResultSet rs=pst1.executeQuery(); rs.last();%> <form action="#"> <table border="2" bgcolor="ccceee" width="1000"> <tr bgcolor="CCCCCC" align="center"> <td>记录条数</td><td>学号</td><td>姓名</td> <td>性别</td><td>电话</td><td>单个删除</td><td>单个还原</td> </tr> <%rs.beforeFirst(); while(rs.next()) { %> <tr align="center"> <td><%=rs.getRow() %></td> <td><%=rs.getString("id") %></td> <td><%=rs.getString("name") %></td> <td><%=rs.getString("sex") %></td> <td><%=rs.getString("tel") %></td> <%int x=Integer.parseInt(rs.getString("id")); %> <%session.setAttribute("id18", x); %> <td><a href="recycle07.jsp">删除</a></td> <td><a href="recycle08.jsp">还原</a></td> </tr> <%} %> </table> </form> <% if(rs!=null){rs.close();} if(pst1!=null){pst1.close();} if(conn!=null){conn.close();} %> <br> <input type="button" name="name1" value="全部还原" onclick="reduction()"> <input type="button" name="name2" value="全部删除" onclick="Delete()"> </center> </body> </html>
<!-- recycle07.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>回收站单个删除页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/"; String dbname="root01"; String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql="delete from recycle where id=?"; PreparedStatement pst=conn.prepareStatement(sql); pst.setInt(1, (int)session.getAttribute("id18")); int n=pst.executeUpdate(); if(n!=0) { out.println("删除"+n+"条记录成功!"); } else { out.println("删除失败!"); } if(pst!=null) pst.close(); if(conn!=null) conn.close(); response.setHeader("refresh", "2;url=recycle01.jsp"); %> </body> </html>
<!-- recycle08.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>回收站单个还原页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/"; String dbname="root01"; String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql="select * from recycle where id=?"; PreparedStatement pst=conn.prepareStatement(sql); pst.setInt(1, (int)session.getAttribute("id18")); ResultSet rs=pst.executeQuery(); PreparedStatement pst2=null; PreparedStatement pst3=null; if(rs.next()) { int id15=rs.getInt("id"); String name15=rs.getString("name"); String sex15=rs.getString("sex"); int tel15=rs.getInt("tel"); String sql2="insert into idcard(id,name,sex,tel) values(?,?,?,?)"; pst2=conn.prepareStatement(sql2); pst2.setInt(1, id15); pst2.setString(2, name15); pst2.setString(3, sex15); pst2.setInt(4, tel15); String sql3="delete from recycle where id=?"; pst3=conn.prepareStatement(sql3); pst3.setInt(1, id15); pst3.execute(); int n2=pst2.executeUpdate(); if(n2!=0){ out.println("回收站还原成功,名片添加"+n2+"条记录!"); }else{ out.println("回收站还原失败!"); } } if(pst!=null) pst.close(); if(conn!=null) conn.close(); if(pst2!=null) pst2.close(); if(pst3!=null) pst3.close(); if(rs!=null) rs.close(); response.setHeader("refresh", "2;url=recycle01.jsp"); %> </body> </html>
<!-- recycle09.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>回收站全部删除页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/"; String dbname="root01"; String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from recycle"; PreparedStatement pst1=conn.prepareStatement(sql1); ResultSet rs=pst1.executeQuery(); PreparedStatement pst2=null; PreparedStatement pst3=null; int sum=0; while(rs.next()) { int id15=rs.getInt("id"); String name15=rs.getString("name"); String sex15=rs.getString("sex"); int tel15=rs.getInt("tel"); String sql3="delete from recycle where id=?"; pst3=conn.prepareStatement(sql3); pst3.setInt(1, id15); pst3.execute(); pst3.executeUpdate(); sum++; } if(true) { out.println("已全部删除"+sum+"条记录!"); } if(pst3!=null) pst3.close(); if(conn!=null) conn.close(); if(rs!=null) rs.close(); if(pst1!=null) pst1.close(); response.setHeader("refresh", "2;url=recycle01.jsp"); %> </body> </html>
<!-- recycle010.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" import="java.sql.*"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>回收站全部还原页面</title> </head> <body> <% request.setCharacterEncoding("UTF-8"); Class.forName("com.mysql.jdbc.Driver"); String url1="jdbc:mysql://localhost:13306/"; String dbname="root01"; String url=url1+dbname; String user="root"; String password="1234"; Connection conn=DriverManager.getConnection(url, user, password); String sql1="select * from recycle"; PreparedStatement pst1=conn.prepareStatement(sql1); ResultSet rs=pst1.executeQuery(); PreparedStatement pst2=null; PreparedStatement pst3=null; int sum=0; while(rs.next()) { int id15=rs.getInt("id"); String name15=rs.getString("name"); String sex15=rs.getString("sex"); int tel15=rs.getInt("tel"); String sql2="insert into idcard(id,name,sex,tel) values(?,?,?,?)"; pst2=conn.prepareStatement(sql2); pst2.setInt(1, id15); pst2.setString(2, name15); pst2.setString(3, sex15); pst2.setInt(4, tel15); String sql3="delete from recycle where id=?"; pst3=conn.prepareStatement(sql3); pst3.setInt(1, id15); pst3.execute(); pst2.executeUpdate(); sum++; } if(true) { out.println("已全部还原"+sum+"条记录!"); } if(pst3!=null) pst3.close(); if(pst2!=null) pst2.close(); if(conn!=null) conn.close(); if(rs!=null) rs.close(); if(pst1!=null) pst1.close(); response.setHeader("refresh", "2;url=recycle01.jsp"); %> </body> </html>
8.功能主页面:
<!-- index_main.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>功能显示页面</title> </head> <frameset rows="130,*"> <frame src="index_title.jsp" scrolling="no"> <frameset cols="300,*"> <frame src="index_left.jsp" name="left" scrolling="no"> <frame src="index_right.jsp" name="right" scrolling="no"> </frameset> </frameset> </html>
<!-- index_left.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>页面菜单</title> </head> <body> <font color="blue" size="5">操作页面</font> <br><br><br><br><br> <p><a href="insert01.jsp" target="right">添加记录</a></p> <p><a href="update01.jsp" target="right">修改记录</a></p> <p><a href="insert01.jsp" target="right">增加记录</a></p> <p><a href="delete01.jsp" target="right">删除记录</a></p> <p><a href="query01.jsp" target="right">查询记录</a></p> <p><a href="recycle01.jsp" target="right">回收站记录</a></p> </body> </html>
<!-- index_right.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>操作显示页面</title> </head> <body bgcolor="white"> <font color="purple"><h1>Hello,world!</h1></font> </body> </html>
<!-- index_title.jsp --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>主标题页面</title> </head> <body> <center> <h1><font color="pink">名片管理系统</font></h1> </center> </body> </html>
以上就是全部代码,可以点个免费的赞支持下吗!!!