TeachClass.jsp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <%@ page language="java" contentType="text/html; charset=UTF-8"
  2. pageEncoding="UTF-8" import="java.sql.*"%>
  3. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  4. <html>
  5. <head>
  6. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  7. <title>Insert title here</title>
  8. </head>
  9. <body>
  10. <p align="center">当天授课信息表</p>
  11. <table align="center" width="50%" border="1">
  12. <tr>
  13. <th>课程名字</th>
  14. <th>授课教师</th>
  15. <th>课程时间</th>
  16. </tr>
  17. <%
  18. request.setCharacterEncoding("utf-8");
  19. Class.forName("com.mysql.jdbc.Driver");
  20. String username = "root";
  21. String url = "jdbc:mysql://127.0.0.1:3306/teamessage?serverTimezone=UTC";
  22. String password = "1314";
  23. Connection conn = DriverManager.getConnection(url,username,password);
  24. String sql = "SELECT * from teachclass";
  25. Statement stmt = conn.createStatement();
  26. ResultSet rs = stmt.executeQuery(sql);
  27. while(rs.next()){
  28. int id = rs.getInt(1);
  29. %>
  30. <tbody>
  31. <tr>
  32. <td><%=rs.getString("ClassName")%></td>
  33. <td><%=rs.getString("ClassTeacherName")%></td>
  34. <td><%=rs.getString("ClassTime")%></td>
  35. <td>
  36. <a href="shaw.jsp?id=<%= id%>"><!-- 通过主键id值来获取到当前行最后删除> -->
  37. <input type="button" value="删除" class="btn btn-warning" >
  38. </a>
  39. </td>
  40. </tr>
  41. </tbody>
  42. <!-- 创建数据库表
  43. create table teachclass
  44. (
  45. id int auto_increment primary key,
  46. ClassName varchar(20),
  47. ClassTeacherName varchar(20),
  48. ClassTime varchar(20),
  49. );
  50. -->
  51. <%
  52. }
  53. rs.close();
  54. stmt.close();
  55. conn.close();
  56. %>
  57. </table>
  58. <p></p>
  59. <p></p>
  60. <div align="center">
  61. <a href="show.jsp">
  62. <input type="button" value="返回首页">
  63. </a>
  64. <a href="addTeacherClass.html">
  65. <input type="button" value="增加信息">
  66. </a>
  67. </div>
  68. </body>
  69. </html>