增加“你是大帅逼”

This commit is contained in:
zzh 2025-02-12 15:59:29 +08:00
parent 1ad04a2354
commit b3790185e2
14 changed files with 9 additions and 844 deletions

View File

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="23" project-jdk-type="JavaSDK">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="11 (2)" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
</project>

View File

@ -1,2 +1,2 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<Context docBase="F:\Coding\JetBrains\Idea\KTT\School-ST\src\main\webapp"/>
<Context docBase="D:\Jetbrains\Coding\Idea\SchoolST\src\main\webapp"/>

View File

@ -35,3 +35,7 @@
127.0.0.1 - - [12/Feb/2025:14:08:05 +0800] "GET /School-ST/evaluate.jsp HTTP/1.1" 200 5788
127.0.0.1 - - [12/Feb/2025:14:08:37 +0800] "GET /School-ST/admin.jsp HTTP/1.1" 200 1332
127.0.0.1 - - [12/Feb/2025:14:08:55 +0800] "GET /School-ST/admin.jsp HTTP/1.1" 200 1332
0:0:0:0:0:0:0:1 - - [12/Feb/2025:15:54:10 +0800] "GET /School-ST HTTP/1.1" 302 -
0:0:0:0:0:0:0:1 - - [12/Feb/2025:15:54:10 +0800] "GET /School-ST/ HTTP/1.1" 404 714
0:0:0:0:0:0:0:1 - - [12/Feb/2025:15:54:10 +0800] "GET /favicon.ico HTTP/1.1" 404 648
0:0:0:0:0:0:0:1 - - [12/Feb/2025:15:54:21 +0800] "GET /School-ST/evaluate.jsp HTTP/1.1" 200 5758

View File

@ -158,5 +158,6 @@
</form>
<div class="hint">请选择学院、老师以及课程,然后进入评教页面。</div>
</div>
<div id="hint">你是大帅比</div>
</body>
</html>

View File

@ -1,211 +0,0 @@
/*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/9.0.98
* Generated at: 2025-02-12 06:08:37 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
public final class admin_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent,
org.apache.jasper.runtime.JspSourceImports {
private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory();
private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
private static final java.util.Set<java.lang.String> _jspx_imports_packages;
private static final java.util.Set<java.lang.String> _jspx_imports_classes;
static {
_jspx_imports_packages = new java.util.LinkedHashSet<>(6);
_jspx_imports_packages.add("java.sql");
_jspx_imports_packages.add("javax.servlet");
_jspx_imports_packages.add("javax.servlet.http");
_jspx_imports_packages.add("javax.servlet.jsp");
_jspx_imports_classes = null;
}
private volatile javax.el.ExpressionFactory _el_expressionfactory;
private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager;
public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
}
public java.util.Set<java.lang.String> getPackageImports() {
return _jspx_imports_packages;
}
public java.util.Set<java.lang.String> getClassImports() {
return _jspx_imports_classes;
}
public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
if (_el_expressionfactory == null) {
synchronized (this) {
if (_el_expressionfactory == null) {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
}
}
}
return _el_expressionfactory;
}
public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
if (_jsp_instancemanager == null) {
synchronized (this) {
if (_jsp_instancemanager == null) {
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
}
}
return _jsp_instancemanager;
}
public void _jspInit() {
}
public void _jspDestroy() {
}
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
if (!javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
final java.lang.String _jspx_method = request.getMethod();
if ("OPTIONS".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
return;
}
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSP 只允许 GET、POST 或 HEAD。Jasper 还允许 OPTIONS");
return;
}
}
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("\r\n");
out.write("<!DOCTYPE html>\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write(" <title>管理员查看评教统计</title>\r\n");
out.write(" <style>\r\n");
out.write(" body {\r\n");
out.write(" font-family: Arial, sans-serif;\r\n");
out.write(" margin: 0;\r\n");
out.write(" padding: 0;\r\n");
out.write(" background-color: #f4f4f4;\r\n");
out.write(" }\r\n");
out.write(" .container {\r\n");
out.write(" width: 80%;\r\n");
out.write(" margin: 0 auto;\r\n");
out.write(" padding: 20px;\r\n");
out.write(" background-color: #fff;\r\n");
out.write(" border-radius: 8px;\r\n");
out.write(" box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);\r\n");
out.write(" }\r\n");
out.write(" h1 {\r\n");
out.write(" text-align: center;\r\n");
out.write(" color: #333;\r\n");
out.write(" }\r\n");
out.write(" table {\r\n");
out.write(" width: 100%;\r\n");
out.write(" border-collapse: collapse;\r\n");
out.write(" margin-top: 20px;\r\n");
out.write(" }\r\n");
out.write(" th, td {\r\n");
out.write(" padding: 12px;\r\n");
out.write(" text-align: left;\r\n");
out.write(" border-bottom: 1px solid #ddd;\r\n");
out.write(" }\r\n");
out.write(" th {\r\n");
out.write(" background-color: #4CAF50;\r\n");
out.write(" color: white;\r\n");
out.write(" }\r\n");
out.write(" tr:hover {\r\n");
out.write(" background-color: #f5f5f5;\r\n");
out.write(" }\r\n");
out.write(" </style>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write("<div class=\"container\">\r\n");
out.write(" <h1>评教统计</h1>\r\n");
out.write(" <table>\r\n");
out.write(" <tr>\r\n");
out.write(" <th>老师姓名</th>\r\n");
out.write(" <th>平均得分</th>\r\n");
out.write(" </tr>\r\n");
out.write(" ");
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()) {
out.println("<tr><td>" + rs.getString("name") + "</td><td>" + rs.getDouble("avg_score") + "</td></tr>");
}
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
out.write("\r\n");
out.write(" </table>\r\n");
out.write("</div>\r\n");
out.write("</body>\r\n");
out.write("</html>");
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try {
if (response.isCommitted()) {
out.flush();
} else {
out.clearBuffer();
}
} catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}

View File

@ -1,7 +1,7 @@
/*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/9.0.98
* Generated at: 2025-02-12 06:08:05 UTC
* Version: Apache Tomcat/9.0.99
* Generated at: 2025-02-12 07:54:21 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
@ -276,8 +276,6 @@ public final class evaluate_jsp extends org.apache.jasper.runtime.HttpJspBase
out.write(" <button type=\"submit\">进入评教页面</button>\r\n");
out.write(" </form>\r\n");
out.write(" <div class=\"hint\">请选择学院、老师以及课程,然后进入评教页面。</div>\r\n");
out.write(" <div class=\"hint\">");
out.write("</div>\r\n");
out.write("</div>\r\n");
out.write("</body>\r\n");
out.write("</html>");

View File

@ -1,296 +0,0 @@
/*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/9.0.98
* Generated at: 2025-02-12 05:54:52 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
import org.json.JSONArray;
import org.json.JSONObject;
public final class evaluationPage_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent,
org.apache.jasper.runtime.JspSourceImports {
private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory();
private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
private static final java.util.Set<java.lang.String> _jspx_imports_packages;
private static final java.util.Set<java.lang.String> _jspx_imports_classes;
static {
_jspx_imports_packages = new java.util.LinkedHashSet<>(6);
_jspx_imports_packages.add("java.sql");
_jspx_imports_packages.add("javax.servlet");
_jspx_imports_packages.add("javax.servlet.http");
_jspx_imports_packages.add("javax.servlet.jsp");
_jspx_imports_classes = new java.util.LinkedHashSet<>(3);
_jspx_imports_classes.add("org.json.JSONObject");
_jspx_imports_classes.add("org.json.JSONArray");
}
private volatile javax.el.ExpressionFactory _el_expressionfactory;
private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager;
public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
}
public java.util.Set<java.lang.String> getPackageImports() {
return _jspx_imports_packages;
}
public java.util.Set<java.lang.String> getClassImports() {
return _jspx_imports_classes;
}
public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
if (_el_expressionfactory == null) {
synchronized (this) {
if (_el_expressionfactory == null) {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
}
}
}
return _el_expressionfactory;
}
public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
if (_jsp_instancemanager == null) {
synchronized (this) {
if (_jsp_instancemanager == null) {
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
}
}
return _jsp_instancemanager;
}
public void _jspInit() {
}
public void _jspDestroy() {
}
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
if (!javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
final java.lang.String _jspx_method = request.getMethod();
if ("OPTIONS".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
return;
}
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSP 只允许 GET、POST 或 HEAD。Jasper 还允许 OPTIONS");
return;
}
}
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("\r\n");
String college = request.getParameter("college");
String teacher = request.getParameter("teacher");
String course = request.getParameter("course");
if (college == null || teacher == null || course == null) {
response.sendRedirect("evaluation.jsp");
return;
}
JSONArray dimensions = new JSONArray();
int totalQuestionCount = 0;
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "SchoolST", "123456");
String sql = "SELECT d.dimension_id, d.name AS dimension_name, d.weight, q.question_id, q.question_text " +
"FROM dimensions d " +
"JOIN questions q ON d.dimension_id = q.dimension_id " +
"ORDER BY d.dimension_id, q.question_id";
Statement stmt = conn.createStatement();
ResultSet rs = stmt.executeQuery(sql);
JSONObject currentDimension = null;
int lastDimensionId = -1;
while (rs.next()) {
int dimensionId = rs.getInt("dimension_id");
if (dimensionId != lastDimensionId) {
if (currentDimension != null) {
dimensions.put(currentDimension);
}
currentDimension = new JSONObject();
currentDimension.put("dimension_id", dimensionId);
currentDimension.put("dimension_name", rs.getString("dimension_name"));
currentDimension.put("weight", rs.getFloat("weight"));
currentDimension.put("questions", new JSONArray());
lastDimensionId = dimensionId;
}
JSONObject question = new JSONObject();
question.put("question_id", rs.getInt("question_id"));
question.put("question_text", rs.getString("question_text"));
currentDimension.getJSONArray("questions").put(question);
totalQuestionCount++;
}
if (currentDimension != null) {
dimensions.put(currentDimension);
}
rs.close();
stmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
out.write("\r\n");
out.write("<!DOCTYPE html>\r\n");
out.write("<html>\r\n");
out.write("<head>\r\n");
out.write(" <title>评教页面</title>\r\n");
out.write(" <style>\r\n");
out.write(" table {\r\n");
out.write(" width: 100%;\r\n");
out.write(" border-collapse: collapse;\r\n");
out.write(" margin-bottom: 20px;\r\n");
out.write(" }\r\n");
out.write(" th, td {\r\n");
out.write(" padding: 10px;\r\n");
out.write(" border: 1px solid #ddd;\r\n");
out.write(" text-align: left;\r\n");
out.write(" }\r\n");
out.write(" th {\r\n");
out.write(" background-color: #f2f2f2;\r\n");
out.write(" }\r\n");
out.write(" .dimension-title {\r\n");
out.write(" font-size: 18px;\r\n");
out.write(" font-weight: bold;\r\n");
out.write(" margin-top: 20px;\r\n");
out.write(" margin-bottom: 10px;\r\n");
out.write(" }\r\n");
out.write(" .question-text {\r\n");
out.write(" font-weight: normal;\r\n");
out.write(" }\r\n");
out.write(" </style>\r\n");
out.write("</head>\r\n");
out.write("<body>\r\n");
out.write("<h1>评教页面</h1>\r\n");
out.write("<form action=\"submitEvaluation.jsp\" method=\"post\" onsubmit=\"return validateForm()\">\r\n");
out.write(" <input type=\"hidden\" name=\"college\" value=\"");
out.print( college );
out.write("\">\r\n");
out.write(" <input type=\"hidden\" name=\"teacher\" value=\"");
out.print( teacher );
out.write("\">\r\n");
out.write(" <input type=\"hidden\" name=\"course\" value=\"");
out.print( course );
out.write("\">\r\n");
out.write("\r\n");
out.write(" ");
for (int i = 0; i < dimensions.length(); i++) {
JSONObject dimension = dimensions.getJSONObject(i);
out.println("<div class='dimension-title'>" + dimension.getString("dimension_name") + "(权重:" + dimension.getFloat("weight") + "%</div>");
out.println("<table>");
out.println("<thead><tr><th>题目</th><th>符合</th><th>不符合</th></tr></thead>");
out.println("<tbody>");
JSONArray questions = dimension.getJSONArray("questions");
for (int j = 0; j < questions.length(); j++) {
JSONObject question = questions.getJSONObject(j);
out.println("<tr>");
out.println("<td class='question-text'>" + question.getString("question_text") + "</td>");
out.println("<td><input type='radio' name='question_" + question.getInt("question_id") + "' value='1' required></td>");
out.println("<td><input type='radio' name='question_" + question.getInt("question_id") + "' value='0' required></td>");
out.println("</tr>");
}
out.println("</tbody></table>");
}
out.write("\r\n");
out.write("\r\n");
out.write(" <button type=\"submit\">提交评价</button>\r\n");
out.write("</form>\r\n");
out.write("\r\n");
out.write("<script>\r\n");
out.write(" const totalQuestionCount = ");
out.print( totalQuestionCount );
out.write(";\r\n");
out.write("\r\n");
out.write(" function validateForm() {\r\n");
out.write(" const allQuestions = document.querySelectorAll(\"input[type='radio']\");\r\n");
out.write(" const answered = new Set();\r\n");
out.write("\r\n");
out.write(" allQuestions.forEach(input => {\r\n");
out.write(" if (input.checked) {\r\n");
out.write(" const questionId = input.name.replace(\"question_\", \"\");\r\n");
out.write(" answered.add(questionId);\r\n");
out.write(" }\r\n");
out.write(" });\r\n");
out.write("\r\n");
out.write(" if (answered.size !== totalQuestionCount) {\r\n");
out.write(" alert(\"请完成所有题目的评价后再提交!\");\r\n");
out.write(" return false;\r\n");
out.write(" }\r\n");
out.write(" return true;\r\n");
out.write(" }\r\n");
out.write("</script>\r\n");
out.write("</body>\r\n");
out.write("</html>");
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try {
if (response.isCommitted()) {
out.flush();
} else {
out.clearBuffer();
}
} catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}

View File

@ -1,172 +0,0 @@
/*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/9.0.98
* Generated at: 2025-02-12 05:54:50 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
import org.json.JSONArray;
import org.json.JSONObject;
public final class loadCourses_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent,
org.apache.jasper.runtime.JspSourceImports {
private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory();
private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
private static final java.util.Set<java.lang.String> _jspx_imports_packages;
private static final java.util.Set<java.lang.String> _jspx_imports_classes;
static {
_jspx_imports_packages = new java.util.LinkedHashSet<>(6);
_jspx_imports_packages.add("java.sql");
_jspx_imports_packages.add("javax.servlet");
_jspx_imports_packages.add("javax.servlet.http");
_jspx_imports_packages.add("javax.servlet.jsp");
_jspx_imports_classes = new java.util.LinkedHashSet<>(3);
_jspx_imports_classes.add("org.json.JSONObject");
_jspx_imports_classes.add("org.json.JSONArray");
}
private volatile javax.el.ExpressionFactory _el_expressionfactory;
private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager;
public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
}
public java.util.Set<java.lang.String> getPackageImports() {
return _jspx_imports_packages;
}
public java.util.Set<java.lang.String> getClassImports() {
return _jspx_imports_classes;
}
public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
if (_el_expressionfactory == null) {
synchronized (this) {
if (_el_expressionfactory == null) {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
}
}
}
return _el_expressionfactory;
}
public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
if (_jsp_instancemanager == null) {
synchronized (this) {
if (_jsp_instancemanager == null) {
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
}
}
return _jsp_instancemanager;
}
public void _jspInit() {
}
public void _jspDestroy() {
}
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
if (!javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
final java.lang.String _jspx_method = request.getMethod();
if ("OPTIONS".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
return;
}
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSP 只允许 GET、POST 或 HEAD。Jasper 还允许 OPTIONS");
return;
}
}
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("application/json; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("\r\n");
String teacherId = request.getParameter("teacher");
JSONArray courses = new JSONArray();
if (teacherId != null && !teacherId.isEmpty()) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "SchoolST", "123456");
String sql = "SELECT * FROM courses WHERE teacher_id = ?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, teacherId);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
JSONObject course = new JSONObject();
course.put("course_id", rs.getInt("course_id"));
course.put("course_name", rs.getString("course_name"));
courses.put(course);
}
rs.close();
pstmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
out.print(courses.toString());
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try {
if (response.isCommitted()) {
out.flush();
} else {
out.clearBuffer();
}
} catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}

View File

@ -1,159 +0,0 @@
/*
* Generated by the Jasper component of Apache Tomcat
* Version: Apache Tomcat/9.0.98
* Generated at: 2025-02-12 05:53:04 UTC
* Note: The last modified time of this file was set to
* the last modified time of the source file after
* generation to assist with modification tracking.
*/
package org.apache.jsp;
import javax.servlet.*;
import javax.servlet.http.*;
import javax.servlet.jsp.*;
import java.sql.*;
public final class loadTeachers_jsp extends org.apache.jasper.runtime.HttpJspBase
implements org.apache.jasper.runtime.JspSourceDependent,
org.apache.jasper.runtime.JspSourceImports {
private static final javax.servlet.jsp.JspFactory _jspxFactory =
javax.servlet.jsp.JspFactory.getDefaultFactory();
private static java.util.Map<java.lang.String,java.lang.Long> _jspx_dependants;
private static final java.util.Set<java.lang.String> _jspx_imports_packages;
private static final java.util.Set<java.lang.String> _jspx_imports_classes;
static {
_jspx_imports_packages = new java.util.LinkedHashSet<>(6);
_jspx_imports_packages.add("java.sql");
_jspx_imports_packages.add("javax.servlet");
_jspx_imports_packages.add("javax.servlet.http");
_jspx_imports_packages.add("javax.servlet.jsp");
_jspx_imports_classes = null;
}
private volatile javax.el.ExpressionFactory _el_expressionfactory;
private volatile org.apache.tomcat.InstanceManager _jsp_instancemanager;
public java.util.Map<java.lang.String,java.lang.Long> getDependants() {
return _jspx_dependants;
}
public java.util.Set<java.lang.String> getPackageImports() {
return _jspx_imports_packages;
}
public java.util.Set<java.lang.String> getClassImports() {
return _jspx_imports_classes;
}
public javax.el.ExpressionFactory _jsp_getExpressionFactory() {
if (_el_expressionfactory == null) {
synchronized (this) {
if (_el_expressionfactory == null) {
_el_expressionfactory = _jspxFactory.getJspApplicationContext(getServletConfig().getServletContext()).getExpressionFactory();
}
}
}
return _el_expressionfactory;
}
public org.apache.tomcat.InstanceManager _jsp_getInstanceManager() {
if (_jsp_instancemanager == null) {
synchronized (this) {
if (_jsp_instancemanager == null) {
_jsp_instancemanager = org.apache.jasper.runtime.InstanceManagerFactory.getInstanceManager(getServletConfig());
}
}
}
return _jsp_instancemanager;
}
public void _jspInit() {
}
public void _jspDestroy() {
}
public void _jspService(final javax.servlet.http.HttpServletRequest request, final javax.servlet.http.HttpServletResponse response)
throws java.io.IOException, javax.servlet.ServletException {
if (!javax.servlet.DispatcherType.ERROR.equals(request.getDispatcherType())) {
final java.lang.String _jspx_method = request.getMethod();
if ("OPTIONS".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
return;
}
if (!"GET".equals(_jspx_method) && !"POST".equals(_jspx_method) && !"HEAD".equals(_jspx_method)) {
response.setHeader("Allow","GET, HEAD, POST, OPTIONS");
response.sendError(HttpServletResponse.SC_METHOD_NOT_ALLOWED, "JSP 只允许 GET、POST 或 HEAD。Jasper 还允许 OPTIONS");
return;
}
}
final javax.servlet.jsp.PageContext pageContext;
javax.servlet.http.HttpSession session = null;
final javax.servlet.ServletContext application;
final javax.servlet.ServletConfig config;
javax.servlet.jsp.JspWriter out = null;
final java.lang.Object page = this;
javax.servlet.jsp.JspWriter _jspx_out = null;
javax.servlet.jsp.PageContext _jspx_page_context = null;
try {
response.setContentType("text/html; charset=UTF-8");
pageContext = _jspxFactory.getPageContext(this, request, response,
null, true, 8192, true);
_jspx_page_context = pageContext;
application = pageContext.getServletContext();
config = pageContext.getServletConfig();
session = pageContext.getSession();
out = pageContext.getOut();
_jspx_out = out;
out.write("\r\n");
out.write("\r\n");
String college = request.getParameter("college");
if (college != null && !college.isEmpty()) {
try {
Class.forName("com.mysql.cj.jdbc.Driver");
Connection conn = DriverManager.getConnection("jdbc:mysql://localhost:3306/test", "SchoolST", "123456");
String sql = "SELECT * FROM teachers WHERE college = ?";
PreparedStatement pstmt = conn.prepareStatement(sql);
pstmt.setString(1, college);
ResultSet rs = pstmt.executeQuery();
while (rs.next()) {
out.println("<option value='" + rs.getInt("teacher_id") + "'>" + rs.getString("name") + "</option>");
}
rs.close();
pstmt.close();
conn.close();
} catch (Exception e) {
e.printStackTrace();
}
}
} catch (java.lang.Throwable t) {
if (!(t instanceof javax.servlet.jsp.SkipPageException)){
out = _jspx_out;
if (out != null && out.getBufferSize() != 0)
try {
if (response.isCommitted()) {
out.flush();
} else {
out.clearBuffer();
}
} catch (java.io.IOException e) {}
if (_jspx_page_context != null) _jspx_page_context.handlePageException(t);
else throw new ServletException(t);
}
} finally {
_jspxFactory.releasePageContext(_jspx_page_context);
}
}
}