13

泪湿孤枕 提交于 2020-02-13 20:43:05

今天继续复习了上学期的内容,更加熟练的掌握了增删改查和登陆界面

以下是完善后的代码

 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 4 <html xmlns="http://www.w3.org/1999/xhtml">
 5 <head>
 6 <meta http-equiv="X-UA-Compatible" content="IE=emulateIE7" />
 7 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 8 <link rel="stylesheet" type="text/css" href="css/style.css" />
 9 <link rel="stylesheet" type="text/css" href="css/WdatePicker.css" />
10 <link rel="stylesheet" type="text/css" href="css/skin_/form.css" />
11 <link href="umeditor/themes/default/_css/umeditor.css" type="text/css"
12     rel="stylesheet">
13 <script type="text/javascript" src="js/jquery.ha.js"></script>
14 <script type="text/javascript" src="js/jquery.select.js"></script>
15 <script type="text/javascript" src="js/WdatePicker.js"></script>
16 <script type="text/javascript">
17     window.UMEDITOR_HOME_URL = 'umeditor/'; // 请换成绝对路径
18 </script>
19 <script type="text/javascript" src="js/umeditor.config.js"></script>
20 <script type="text/javascript" src="js/editor_api.js"></script>
21 <script type="text/javascript" src="umeditor/lang/zh-cn/zh-cn.js"></script>
22 <title>基础信息</title>
23 </head>
24 
25 <body>
26     <form action="binsert.jsp" method="post" id="form"
27         onSubmit="return validate()">
28         <div id="container">
29             <div id="hd"></div>
30             <div id="bd">
31                 <div id="main">
32                     <h2 class="subfild">
33                         <span>基本信息</span>
34                     </h2>
35 
36                         <div class="kv-item ue-clear">
37                             <label><span class="impInfo">*</span>部门名称</label>
38                             <div class="kv-item-content">
39                                 <input type="text" name="name" placeholder="部门名称" />
40                             </div>
41                             <span class="kv-item-tip">部门名称限制在35个字符</span>
42                         </div>
43 
44                         <div class="kv-item ue-clear">
45                             <label>部门编号</label>
46                             <div class="kv-item-content">
47                                 <select name="addresss">
48                                     <option>01:办公室</option>
49                                     <option>02:财务部门</option>
50                                     <option>03:销售部门</option>
51                                     <option>04:生产一部</option>
52                                     <option>05:生产二部</option>
53                                     <option>06:生产三部</option>
54                                 </select>
55                             </div>
56                         </div>
57                     </div>
58 
59                     <input class="button" type="submit" value="确认提交" />
60                 </div>
61             </div>
62         </div>
63     </form>
64 </body>
65 <script type="text/javascript" language="JavaScript">
66     function validate() {
67         var name = document.forms[0].name.value;
68         var addresss = document.forms[0].addresss.value;
69         if (name.length <= 0) {
70             alert("部门名称不能为空,请输入部门名称!");
71             return false;
72         } else if (addresss.length <= 0) {
73             alert("部门编号不能为空,请输入部门编号!");
74             return false;
75         } else {
76             return true;
77         }
78     }
79 </script>
80 <script type="text/javascript">
81     $('select').select();
82     showRemind('input[type=text],textarea', 'color5');
83     UM.getEditor('content');
84 </script>
85 </html>
 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <%@ page import="java.sql.*"%>
 4 <%@ page import="com.web.fmd.DBUtil"%>
 5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 6 <html xmlns="http://www.w3.org/1999/xhtml">
 7 <head>
 8 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 9 <title>删除学生信息</title>
10 
11 <script type="text/javascript" src="js/jquery.min.js"></script>
12 
13 <link rel="stylesheet" href="css/add.css" type="text/css" media="screen" />
14 <link rel="stylesheet" href="utilLib/bootstrap.min.css" type="text/css" media="screen" />
15 
16 </head>
17 <body>
18     <%
19         request.setCharacterEncoding("UTF-8"); //设置响应的编码为UTF-8
20         String name = request.getParameter("name");
21         Connection conn = null; //定义静态数据库连接 //定义静态数据库连接
22         Statement stat = null;
23         ResultSet rs = null; //将rs滞空。
24         conn = DBUtil.getConnection();
25         stat = conn.createStatement();
26         stat.executeUpdate("delete from bumen where name = '" + name + "'"); 
27         rs = stat.executeQuery("select * from bumen"); //查找data表
28         if (rs.next()) //判断结果集
29         {
30             out.print("<center><br><br><h3>删除成功!</h3></center>");
31         }
32         else {
33             out.print("<center><h3>删除失败!</h3></center>");
34         }
35     %>
36     <br>
37     <br>
38     <%
39         if (rs != null) {
40             rs.close(); //关闭结果集,但是rs还是有null值。
41             rs = null; //将rs滞空。
42         }
43         if (stat != null) {
44             stat.close(); //关闭stat。
45             stat = null; //滞空stat。
46         }
47         if (conn != null) {
48             conn.close(); //关闭数据库连接
49             conn = null;
50         }
51     %>
52 </body>
53 </html>
 1 <%@ page language="java" contentType="text/html; charset=UTF-8"
 2     pageEncoding="UTF-8"%>
 3 <%@ page import="java.sql.*"%>
 4 <%@ page import="com.web.fmd.DBUtil"%>
 5 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
 6 <html xmlns="http://www.w3.org/1999/xhtml">
 7 <head>
 8 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
 9 <title>添加部门信息</title>
10 
11 <script type="text/javascript" src="js/jquery.min.js"></script>
12 
13 <link rel="stylesheet" href="css/add.css" type="text/css" media="screen" />
14 <link rel="stylesheet" href="utilLib/bootstrap.min.css" type="text/css" media="screen" />
15 
16 </head>
17 <body>
18     <%
19         request.setCharacterEncoding("UTF-8"); //设置响应的编码为UTF-8
20         String name = request.getParameter("name");
21         String addresss = request.getParameter("addresss");
22         Connection conn = null; //定义静态数据库连接 
23         Statement stat = null;
24         ResultSet rs = null; //将rs滞空。
25         conn = DBUtil.getConnection();
26         stat = conn.createStatement();
27         //String sql = ; //向对应的数据字段添加数据
28         stat.executeUpdate("insert into bumen(name,addresss) values('" + name + "','" + addresss +"')");
29         rs = stat.executeQuery("select * from bumen"); //查找data表
30     %>
31     <center>
32         <%
33             if (rs.next()) {
34                 out.print("<br><h3>部门信息添加成功!</h3>");
35             } 
36             else {
37                 out.print("<br><h3>部门信息添加失败!</h3>");
38             }
39         %>
40     </center>
41     <%
42         if (rs != null) {
43             rs.close(); //关闭结果集,但是rs还是有null值。
44             rs = null; //将rs滞空。
45         }
46         if (stat != null) {
47             stat.close(); //关闭stat。
48             stat = null; //滞空stat。
49         }
50         if (conn != null) {
51             conn.close(); //关闭数据库连接
52             conn = null;
53         }
54     %>
55 </body>
56 </html>

这是一整个增删改查的代码

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!