diff --git a/.idea/School-ST.iml b/.idea/School-ST.iml
index b23e517..16e0a48 100644
--- a/.idea/School-ST.iml
+++ b/.idea/School-ST.iml
@@ -1,41 +1,10 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
\ No newline at end of file
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000..42272ec
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,18 @@
+
+
+
+
+ mysql.8
+ true
+ com.mysql.cj.jdbc.Driver
+ jdbc:mysql://localhost:3306
+
+
+
+
+
+
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/.idea/libraries/lib.xml b/.idea/libraries/lib.xml
new file mode 100644
index 0000000..02ccf5e
--- /dev/null
+++ b/.idea/libraries/lib.xml
@@ -0,0 +1,9 @@
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/.idea/webContexts.xml b/.idea/webContexts.xml
new file mode 100644
index 0000000..22eada7
--- /dev/null
+++ b/.idea/webContexts.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/conf/Catalina/localhost/School-ST.xml b/conf/Catalina/localhost/School-ST.xml
index 83ce4c1..5f7a038 100644
--- a/conf/Catalina/localhost/School-ST.xml
+++ b/conf/Catalina/localhost/School-ST.xml
@@ -1,2 +1,6 @@
-
+
+
+
+
+
diff --git a/src/main/webapp/admin.jsp b/src/main/webapp/admin.jsp
index 091c83d..3ab6378 100644
--- a/src/main/webapp/admin.jsp
+++ b/src/main/webapp/admin.jsp
@@ -51,14 +51,20 @@
平均得分 |
<%
- try {//加载数据库驱动
- Class.forName("com.mysql.cj.jdbc.Driver");//连接数据库
- Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "SchoolST", "123456");//查询语句
- String sql = "SELECT t.name, AVG(e.total_score) as avg_score FROM teachers t JOIN evaluations e ON t.teacher_id = e.teacher_id GROUP BY t.teacher_id";//创建Statement对象
- Statement stmt = conn.createStatement();//执行查询
- ResultSet rs = stmt.executeQuery(sql);//遍历结果集
- while (rs.next()) {//输出结果 //老师姓名 //平均得分
- out.println("" + rs.getString("name") + " | " + rs.getDouble("avg_score") + " |
");//关闭连接
+ try {
+ Class.forName("com.mysql.cj.jdbc.Driver");
+ Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "SchoolST", "123456");
+ String sql = "SELECT t.name, AVG(e.total_score) as avg_score FROM teachers t JOIN evaluations e ON t.teacher_id = e.teacher_id GROUP BY t.teacher_id";
+ Statement stmt = conn.createStatement();
+ ResultSet rs = stmt.executeQuery(sql);
+ while (rs.next()) {
+ // 使用 JSP 表达式输出内容
+ %>
+
+ <%= rs.getString("name") %> |
+ <%= rs.getDouble("avg_score") %> |
+
+ <%
}
rs.close();
stmt.close();
@@ -70,4 +76,4 @@