今天并没有进行新的学习,而是对上学期的学习内容进行了整理和复习
主要复习的板块就是关于数据库的增删改查和登陆界面的完成
不同于之前,今天主要复习了查询功能的模糊查询
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%--设置页面的脚本支持语言为java—导入util包中的类—申明编码方式为UTF-8--%> 2 <%@ page import="java.sql.*"%> <%--导入java中的sql包--%> 3 <%@page import="ccc.S"%> 4 <% 5 request.setCharacterEncoding("UTF-8"); //设置响应的编码为UTF-8 6 response.setCharacterEncoding("UTF-8"); //设置响应的编码为UTF-8 7 %> 8 <% 9 String path = request.getContextPath(); //相对Path设置 10 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; //相对Path设置 11 %> 12 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%--文档声明--%> 13 <html> 14 <head> 15 <title>志愿者信息</title> <%--页面标题--%> 16 </head> 17 <body> 18 <% 19 String name = request.getParameter("name"); 20 String sex = request.getParameter("sex"); 21 String minzu = request.getParameter("minzu"); 22 String time = request.getParameter("time"); 23 String age = request.getParameter("age"); 24 String mianmao = request.getParameter("mianmao"); 25 String lei = request.getParameter("lei"); 26 Connection conn = null; //定义静态数据库连接 27 Statement stat = null; 28 ResultSet rs = null; //将rs滞空。 29 conn =S.getConnection(); 30 stat = conn.createStatement(); 31 rs = stat.executeQuery("select * from food"); //查找data表 32 %> 33 <br> 34 <h2>志愿者信息</h2> <%--标题样式2--%> 35 <hr noshade> 36 <br> 37 38 <br> 39 <form action="select_for_name.jsp" method="post"> <%--post方法跳转到select_for_age.jsp文件--%> 40 <h3>按姓名查询: 41 <input type="text" name="name" value="" title="姓名不能为空" ></input> 42 <tr> 43 <td> <select name="mianmao" οnchange="showUser(this.value)"> 44 <option value="并且">并且</option> 45 <option value="或者">或者</option> 46 <option value="不含">不含</option> 47 </select> 48 </td> 49 </tr> 50 <input type="submit" value="查询"/> 51 <br> 52 </h3> 53 </form> 54 <form action="select_for_money.jsp" method="post"> <%--post方法跳转到select_for_gender.jsp文件--%> 55 <h3> 按性别查询: 56 <input type="text" name="sex" value="" title="性别不能为空"></input> 57 <tr> 58 <td> <select name="mianmao" οnchange="showUser(this.value)"> 59 <option value="并且">并且</option> 60 <option value="或者">或者</option> 61 <option value="不含">不含</option> 62 </select> 63 </td> 64 </tr> 65 <input type="submit" value="查询"/> 66 <br> 67 </h3> 68 </form> 69 <form action="select_for_id.jsp" method="post"> <%--post方法跳转到select_for_major.jsp文件--%> 70 <h3> 按民族查询: 71 <input type="text" name="minzu" value="" title="民族不能为空"></input> 72 <tr> 73 <td> <select name="mianmao" οnchange="showUser(this.value)"> 74 <option value="并且">并且</option> 75 <option value="或者">或者</option> 76 <option value="不含">不含</option> 77 </select> 78 </td> 79 </tr> 80 <input type="submit" value="查询"/> 81 <br> 82 </h3> 83 </form> 84 <form action="select_for_time.jsp" method="post"> <%--post方法跳转到select_for_major.jsp文件--%> 85 <h3> 按注册时间查询: 86 <input type="text" name="time" value="" title="注册时间不能为空"></input> 87 <tr> 88 <td> <select name="mianmao" οnchange="showUser(this.value)"> 89 <option value="并且">并且</option> 90 <option value="或者">或者</option> 91 <option value="不含">不含</option> 92 </select> 93 </td> 94 </tr> 95 <input type="submit" value="查询"/> 96 <br> 97 </h3> 98 </form> 99 <form action="select-_for-mianmao.jsp" method="post"> <%--post方法跳转到select_for_age.jsp文件--%> 100 <h3>按政治面貌查询: 101 <input type="text" name="mianmao" value="" title="政治面貌不能为空" ></input> 102 <tr> 103 <td> <select name="mianmao" οnchange="showUser(this.value)"> 104 <option value="并且">并且</option> 105 <option value="或者">或者</option> 106 <option value="不含">不含</option> 107 </select> 108 </td> 109 </tr> 110 <input type="submit" value="查询"/> 111 <br> 112 </h3> 113 </form> 114 <form action="select-for-lei.jsp" method="post"> <%--post方法跳转到select_for_age.jsp文件--%> 115 <h3>按姓名查询: 116 <input type="text" name="lei" value="" title="服务类别不能为空" ></input> 117 <tr> 118 <td> <select name="mianmao" οnchange="showUser(this.value)"> 119 <option value="并且">并且</option> 120 <option value="或者">或者</option> 121 <option value="不含">不含</option> 122 </select> 123 </td> 124 </tr> 125 <input type="submit" value="查询"/> 126 <br> 127 </h3> 128 </form> 129 <a href=index.jsp>返回主页面</a> 130 <% 131 if(rs != null) 132 { 133 rs.close(); //关闭结果集,但是rs还是有null值。 134 rs = null; //将rs滞空。 135 } 136 if(stat != null) 137 { 138 stat.close(); //关闭stat。 139 stat = null; //滞空stat。 140 } 141 if(conn != null) 142 { 143 conn.close(); //关闭数据库连接 144 conn = null; 145 } 146 %> 147 </body> 148 </html>
1 <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <%--设置页面的脚本支持语言为java—导入util包中的类—申明编码方式为UTF-8--%> 2 <%@ page import="java.sql.*"%> <%--导入java中的sql包--%> 3 <%@page import="ccc.S"%> 4 <% 5 request.setCharacterEncoding("UTF-8"); //设置响应的编码为UTF-8 6 response.setCharacterEncoding("UTF-8"); //设置响应的编码为UTF-8 7 %> 8 <% 9 String path = request.getContextPath(); //相对Path设置 10 String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; //相对Path设置 11 %> 12 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <%--文档声明--%> 13 <html> 14 <head> 15 <base href="<%=basePath%>"> <%--设置基础路径,basepath为变量--%> 16 <title>按民族查询</title> <%--页面标题--%> 17 </head> 18 <body> 19 <% 20 String minzu = request.getParameter("minzu"); 21 Connection conn = null; //定义静态数据库连接 22 Statement stat = null; //滞空stat。 23 ResultSet rs = null; //将rs滞空。 24 conn = S.getConnection(); 25 stat = conn.createStatement(); 26 rs = stat.executeQuery("select * from food where minzu like '%" + minzu + "%'");//查找data表name字段 27 %> 28 <br> 29 <h3>符合条件的菜品信息</h3> <%--标题样式3--%> 30 <hr noshade> 31 <br> 32 <table width="450" border="100" cellSpacing=1 style="font-size:15pt;border:dashed 1pt"> <%--表格宽度450--%> 33 <tr> 34 <td width="110">姓名</td> 35 <td width="110">性别</td> 36 <td width="211">民族</td> 37 <td width="211">注册时间</td> 38 <td width="211">年龄</td> 39 <td width="211">政治面貌</td> 40 <td width="211">服务类型</td> 41 </tr> 42 <% 43 while(rs.next()) 44 { 45 out.print("<tr>"); 46 out.print("<td>" + rs.getString("name") + "</td>"); //输出name内容 47 out.print("<td>" + rs.getString("sex") + "</td>"); //输出gender内容 48 out.print("<td>" + rs.getString("minzu") + "</td>"); 49 out.print("<td>" + rs.getString("time") + "</td>"); //输出major内容 50 out.print("<td>" + rs.getString("age") + "</td>"); 51 out.print("<td>" + rs.getString("mianmao") + "</td>"); 52 out.print("<td>" + rs.getString("lei") + "</td>"); 53 %> 54 <td><a href="delete.jsp?name=<%=rs.getString("name") %>">删除</a></td> 55 <td><a href="update.jsp?name=<%=rs.getString("name") %>">修改</a></td> 56 <% 57 out.print("</tr>"); 58 } 59 60 61 %> 62 </table> 63 <br> 64 <a href=show.jsp>返回信息查询页面</a> 65 <% 66 if(rs != null) 67 { 68 rs.close(); //关闭结果集,但是rs还是有null值。 69 rs = null; //将rs滞空。 70 } 71 if(stat != null) //判断stat是否滞空。 72 { 73 stat.close(); //关闭stat。 74 stat = null; //滞空stat。 75 } 76 if(conn != null) 77 { 78 conn.close(); //关闭数据库连接 79 conn = null; 80 } 81 %> 82 </body> 83 </html>
来源:https://www.cnblogs.com/xueqiuxiang/p/12300375.html