update.jsp 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  1. <%@page import="java.sql.ResultSet"%>
  2. <%@page import="java.sql.PreparedStatement"%>
  3. <%@page import="java.sql.Statement"%>
  4. <%@page import="java.sql.DriverManager"%>
  5. <%@page import="java.sql.Connection"%>
  6. <%@ page language="java" contentType="text/html; charset=UTF-8"
  7. pageEncoding="UTF-8"%>
  8. <!DOCTYPE html>
  9. <html>
  10. <head>
  11. <meta charset="UTF-8">
  12. <title>Insert title here</title>
  13. <style type="text/css">
  14. *{
  15. margin: 0;
  16. padding: 0;
  17. }
  18. body{
  19. padding: 10px 50px;
  20. }
  21. #wrap{
  22. width: 800px;
  23. margin: 10px auto;
  24. font-family: 'trebuchet MS','Lucida sans',Arial;/*字体效果*/
  25. font-size: 14px;
  26. color: #444;
  27. }
  28. table{
  29. *border-collapse:collapse;/*border-collapse用于表格属性,表示表格的两边框合并成一条*/
  30. border-spacing: 0;/*border-spacing属性设置相邻单元格的边框的距离*/
  31. width: 100%;
  32. }
  33. /*======bordered table======*/
  34. /*-moz代表firefox浏览器私有属性,-ms代表ie浏览器私有属性,-webkit代表safari、chrome私有属性。这些是为了兼容老版本的写法,比较新版本的浏览器都支持直接写:border-radius。*/
  35. .bordered{
  36. border: solid #ccc 1px;
  37. -moz-border-radius:6px;
  38. -webkit-border-radius:6px;
  39. border-radius: 6px; /*添加圆角边框:*/
  40. -wekit-box-shadow:0 1px 1px #ccc;
  41. -moz-box-shadow:0 1px 1px #ccc;
  42. box-shadow: 0 1px 1px #ccc; /*向方框添加阴影。*/
  43. }
  44. .bordered tr{
  45. -o-transition:all 0.1s ease-in-out;/*过渡效果*/
  46. -webkit-transition:all 0.1s ease-in-out;
  47. -moz-transition:all 0.1s ease-in-out;
  48. -ms-transition:all 0.1s ease-in-out;
  49. transition:all 0.1s ease-in-out;
  50. }
  51. .bordered highlight,.bordered tr:hover{background: #fbf8e9;} /*hover:当鼠标经过时会颜色的变化*/
  52. .bordered td,.bordered th{
  53. border-left: 1px solid #ccc;
  54. border-top: 1px solid #ccc;
  55. padding: 10px;
  56. text-align: left; /*左对齐元素中的文本*/
  57. }
  58. .bordered th{
  59. border-color: #dce9f9; /*-webkit safari、chrome私有属性 linear-gradient()函数用于创建一个线性渐变的 "图像"*/
  60. background-image: -webkit-gradient(linear,left top,left bottom,from(#ebf3fc),to(#dce9f9));
  61. background-image: -webkit-linear-gradient(top,#ebf3fc,#dce9f9);
  62. background-image: -moz-linear-gradient(top,#ebf3fc,#dce9f9);
  63. background-image: -ms-linear-gradient(top,#ebf3fc,#dce9f9);
  64. background-image: -o-linear-gradient(top,#ebf3fc,#dce9f9);
  65. background-image: linear-gradient(top,#ebf3fc,#dce9f9);
  66. filter: progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#ebf3fc,endColorstr=#dce9f9); /*ie提供的css渲染*/
  67. -ms-filter: "progid:DXImageTransform.Microsoft.gradient(GradientType=0,startColorstr=#ebf3fc,endColorstr=#dce9f9)";
  68. -webkit-box-shadow:0 1px 0 raba(255,255,255,.8) inset; /*ie提供的css渲染*/
  69. -moz-box-shadow:0 1px 0 raba(255,255,255,.8) inset;
  70. box-shadow:0 1px 0 raba(255,255,255,.8) inset; /*内阴影*/
  71. border-top: none;
  72. text-shadow:0 1px 0 raba(255,255,255,.5);
  73. }
  74. .bordered td:first-child,.bordered th:first-child{
  75. border-left: none;
  76. }
  77. .bordered th:first-child{
  78. -moz-border-radius:6px 0 0 0;
  79. -webkit-border-radius:6px 0 0 0;
  80. border-radius:6px 0 0 0;
  81. }
  82. .bordered th:last-child{
  83. -moz-border-radius:0 6px 0 0;
  84. -webkit-border-radius:0 6px 0 0;
  85. border-radius:0 6px 0 0;
  86. }
  87. .bordered tr:last-child td:first-child{
  88. -moz-border-radius:0 0 0 6px;
  89. -webkit-border-radius:0 0 0 6px;
  90. border-radius:0 0 0 6px;
  91. }
  92. .bordered tr:last-child td:last-child{
  93. -moz-border-radius:0 0 6px 0;
  94. -webkit-border-radius:0 0 6px 0;
  95. border-radius:0 0 6px 0;
  96. }
  97. .a{
  98. color:blue;
  99. }
  100. .button{
  101. background: url(images/button-bg.png) repeat-x top center;
  102. border: 1px solid #999;
  103. -moz-border-radius:4px;
  104. -webkit-border-radius:4px;
  105. border-radius:4px;
  106. padding: 5px;
  107. color: black;
  108. font-weight: bold;
  109. font-size: 13px;
  110. width: 70px;
  111. }
  112. .button:hover{
  113. background: white;
  114. color: black;
  115. }
  116. </style>
  117. </head>
  118. <body>
  119. <table align="center" border="1" width="80%" class="bordered">
  120. <tr>
  121. <th>序号</th>
  122. <th>姓名</th>
  123. <th>性别</th>
  124. <th>电话</th>
  125. <th>邮箱</th>
  126. <th>年龄</th>
  127. <th>部门</th>
  128. <th>操作</th>
  129. </tr>
  130. <%
  131. String key=request.getParameter("name");
  132. String driver="com.mysql.cj.jdbc.Driver";
  133. String url="jdbc:mysql://localhost:3306/edu?characterEncoding=utf-8"
  134. + "&serverTimezone=UTC";
  135. String user="root";
  136. String password="1234";
  137. Class.forName(driver);
  138. Connection conn=DriverManager.getConnection(url,user,password);
  139. //插入数据
  140. String sql="SELECT*FROM manager1 where name=?";
  141. PreparedStatement pstmt=conn.prepareStatement(sql);
  142. pstmt.setString(1, key);
  143. ResultSet rs = pstmt.executeQuery();
  144. int i=1;
  145. while(rs.next()) {
  146. %>
  147. <%
  148. out.println("<tr>");
  149. out.println("<td name=\"count\">" + rs.getString("count") + "</td>");
  150. out.println("<td id='name'>" + rs.getString("name") + "</td>");
  151. out.println("<td>" + rs.getString("gender") + "</td>");
  152. out.println("<td>" + rs.getString("telephone") + "</td>");
  153. out.println("<td>" + rs.getString("mailbox") + "</td>");
  154. out.println("<td>" + rs.getInt("age") + "</td>");
  155. out.println("<td>" + rs.getString("department") + "</td>");
  156. out.println("<td><div><a href='../delete?count=" + rs.getString("count") + "'><button>删除</button></a></div><div><a href='change.jsp?count=" + rs.getString("count") + "'><button>修改</button></a></div></td>");
  157. out.println("</tr>");
  158. %>
  159. </table>
  160. <%
  161. }
  162. pstmt.close();
  163. conn.close();
  164. %>
  165. </body>
  166. </html>