<%@ page language="java" import="java.sql.*" pageEncoding="utf-8"%> <%@ page errorPage="error.jsp"%> <html> <head> <title>学生信息管理系统</title> <link rel="stylesheet" type="text/css" href="css/style.css"> </head> <body> <h1>学生信息管理系统</h1> <a href="add.jsp">添加学生信息</a> <br /> <br /> <table style=" 50%;"> <tr> <th>学号</th> <th>姓名</th> <th>性别</th> <th>出生日期</th> <th>地址</th> <th>管理</th> </tr> <% try { Class.forName("com.mysql.cj.jdbc.Driver"); Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/web_lab03?&useSSL=false&serverTimezone=UTC", "root", "password"); //使用Statement对象 Statement stmt = con.createStatement(); ResultSet rs = stmt.executeQuery("select * from student"); /* PreparedStatement stmt = con.prepareStatement("select * from bookinfo"); ResultSet rs = stmt.executeQuery(); */ while (rs.next()) { String uid = rs.getString(1); out.println("<tr><td>" + rs.getString(1) + "</td><td>" + rs.getString(2) + "</td><td>" + rs.getString(3) + "</td><td>" + rs.getString(4) + "</td><td>" + rs.getString(5) + "</td><td><a href='edit.jsp?uid=" + uid + "'>修改</a> <a href='del.jsp?uid=" + uid + "'>删除</a></td></tr>"); } rs.close(); stmt.close(); con.close(); } catch (Exception e) { out.println("Exception:" + e.getMessage()); } %> </table> </body> </html>