|
@@ -0,0 +1,72 @@
|
|
|
+<%@ page language="java" contentType="text/html; charset=UTF-8"
|
|
|
+ pageEncoding="UTF-8" import="java.sql.*"%>
|
|
|
+
|
|
|
+<!DOCTYPE html>
|
|
|
+<html>
|
|
|
+<head>
|
|
|
+<meta charset="UTF-8">
|
|
|
+<title>Insert title here</title>
|
|
|
+
|
|
|
+
|
|
|
+<style type="text/css">
|
|
|
+tr:nth-child(2n){ background: #f3f3f3;}
|
|
|
+table{width:650px;border:2px;line-height:25px}
|
|
|
+.button{margin-top:20px;margin-left:90px}
|
|
|
+a{padding-left:20px;}
|
|
|
+button{border-radius:10px;height:30px;color:white;background-color:#5ACDCD;border:1px solid #5ACDCD;}
|
|
|
+
|
|
|
+</style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+
|
|
|
+<table border="1" cellspacing="0" cellpadding="1">
|
|
|
+
|
|
|
+<tr>
|
|
|
+<th align="center">user</th>
|
|
|
+<th align="center">name</th>
|
|
|
+<th align="center">password</th>
|
|
|
+<th align="center">sex</th>
|
|
|
+<th align="center">national</th>
|
|
|
+<th align="center">telephone</th>
|
|
|
+<th align="center">age</th>
|
|
|
+</tr>
|
|
|
+
|
|
|
+<%
|
|
|
+try{
|
|
|
+Class.forName("com.mysql.jdbc.Driver");
|
|
|
+String url="jdbc:mysql://localhost:3306/edu?"+"useUnicode=true&characterEncoding=utf-8";
|
|
|
+String user="root";
|
|
|
+String password="1009";
|
|
|
+Connection con=DriverManager.getConnection(url,user,password);
|
|
|
+Statement stmt=con.createStatement();
|
|
|
+ResultSet rs=stmt.executeQuery("select * from student");
|
|
|
+while(rs.next()){
|
|
|
+%>
|
|
|
+<tr>
|
|
|
+<td align="center"><%=rs.getString("user") %></td>
|
|
|
+<td align="center"><%=rs.getString("name") %></td>
|
|
|
+<td align="center"><%=rs.getString("password") %></td>
|
|
|
+<td align="center"><%=rs.getString("sex") %></td>
|
|
|
+<td align="center"><%=rs.getString("national") %></td>
|
|
|
+<td align="center"><%=rs.getString("telephone") %></td>
|
|
|
+<td align="center"><%=rs.getString("age") %></td>
|
|
|
+</tr>
|
|
|
+<%
|
|
|
+}
|
|
|
+rs.close();
|
|
|
+stmt.close();
|
|
|
+con.close();
|
|
|
+}catch(Exception e){
|
|
|
+e.printStackTrace();
|
|
|
+}
|
|
|
+%>
|
|
|
+</table>
|
|
|
+<div class="button">
|
|
|
+<a href="http://localhost:8080/JDBC/stu.jsp"><button>添加数据</button></a>
|
|
|
+<a href="student.pdf"><button>导出pdf文件</button></a>
|
|
|
+<a href="student.xls"><button>导出Excel文件</button></a>
|
|
|
+<a href="#"><button>Excel导入数据库</button></a>
|
|
|
+
|
|
|
+</div>
|
|
|
+</body>
|
|
|
+</html>
|