index:
<%@ 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>
</tr>
<%
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection con = DriverManager.getConnection(
"jdbc:mysql://localhost:3306/student?useUnicode=true&characterEncoding=utf-8&serverTimezone=UTC&useSSL=false",
"root", "123456");
//使用Statement对象
Statement stmt = con.createStatement();
ResultSet rs = stmt.executeQuery("select * from studentinfo");
/*
PreparedStatement stmt = con.prepareStatement("select * from bookinfo");
ResultSet rs = stmt.executeQuery();
*/
while (rs.next()) {
int id = rs.getInt(1);
out.println("<tr><td>" + id + "</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?id=" + id
+ "'>修改</a> <a href='del.jsp?id=" + id + "'>删除</a></td></tr>");
}
rs.close();
stmt.close();
con.close();
} catch (Exception e) {
out.println("Exception:" + e.getMessage());
}
%>
</table>
<br />
<hr />
<div
style="text-align: center; 100%; font-size: 12px; color: #333;">
</div>
</body>
</html>
<%@ page language="java" isErrorPage="true" pageEncoding="utf-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>error page</title>
</head>
<body>
错误信息为:<br/>
<%=exception.getMessage()%><br>
<%=exception.toString()%>
</body>
</html>