From eeb72d06b207a2c1eef200762560fbb89e5df073 Mon Sep 17 00:00:00 2001
From: Zhang HaoYang <1304907854@qq.com>
Date: Sun, 2 Jul 2023 11:58:36 +0800
Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
helloGithub.iml | 4 ++--
src/com/hellogithub/dao/projectDao.java | 2 +-
src/com/hellogithub/servlet/countNumServlet.java | 4 +++-
src/com/hellogithub/servlet/latestServlet.java | 9 +++++++--
4 files changed, 13 insertions(+), 6 deletions(-)
diff --git a/helloGithub.iml b/helloGithub.iml
index 08d1f59..7c99082 100644
--- a/helloGithub.iml
+++ b/helloGithub.iml
@@ -17,8 +17,8 @@
-
+
-
+
\ No newline at end of file
diff --git a/src/com/hellogithub/dao/projectDao.java b/src/com/hellogithub/dao/projectDao.java
index aded764..34fc029 100644
--- a/src/com/hellogithub/dao/projectDao.java
+++ b/src/com/hellogithub/dao/projectDao.java
@@ -41,7 +41,7 @@ public class projectDao {
try {
Connection conn = JdbcUtils.getConnection();
QueryRunner runner = new QueryRunner();
- String sql = "select * from project Group BY periodicals DESC limit 1";
+ String sql = "select * from project Order BY periodicals DESC limit 1";
projectEntity = runner.query(conn, sql, new BeanHandler<>(projectEntity.class));
conn.close();
} catch (SQLException e) {
diff --git a/src/com/hellogithub/servlet/countNumServlet.java b/src/com/hellogithub/servlet/countNumServlet.java
index fde58ae..3bd5db4 100644
--- a/src/com/hellogithub/servlet/countNumServlet.java
+++ b/src/com/hellogithub/servlet/countNumServlet.java
@@ -12,6 +12,7 @@ import jakarta.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
+//项目总数接口
@WebServlet("/countNum")
public class countNumServlet extends HttpServlet {
private projectService projectService=new projectService();
@@ -39,9 +40,10 @@ public class countNumServlet extends HttpServlet {
resp.setContentType("application/json;charset=UTF-8");
PrintWriter writer = resp.getWriter();
- String str= "num:"+projectService.countAll();
+ String str= String.valueOf(projectService.countAll());
String jsonString = JSONObject.toJSONString(str);
writer.println(jsonString);
writer.close();
}
+
}
diff --git a/src/com/hellogithub/servlet/latestServlet.java b/src/com/hellogithub/servlet/latestServlet.java
index fd140d2..2002bc2 100644
--- a/src/com/hellogithub/servlet/latestServlet.java
+++ b/src/com/hellogithub/servlet/latestServlet.java
@@ -19,7 +19,7 @@ public class latestServlet extends HttpServlet {
private com.hellogithub.service.projectService projectService=new projectService();
@Override
public void init(ServletConfig config) throws ServletException {
-
+ super.init(config);
}
@Override
@@ -42,7 +42,7 @@ public class latestServlet extends HttpServlet {
//返回最新期刊数字
PrintWriter writer = resp.getWriter();
String jsonString = JSONObject.toJSONString(projectService.latestNum());
- setResultOK("success",writer);
+// setResultOK("success",writer);
writer.println(jsonString);
writer.close();
}
@@ -63,5 +63,10 @@ public class latestServlet extends HttpServlet {
public void setResultOK(String msg, PrintWriter writer) {
setResult(200, msg, writer);
}
+
+ @Override
+ public void destroy() {
+ super.destroy();
+ }
}