From 719a43306402fdba155e6498d1401782f649ccbd Mon Sep 17 00:00:00 2001 From: sjm <2431685932@qq.com> Date: Wed, 5 Jul 2023 00:59:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=AD=A3=E6=A0=B9=E6=8D=AE=E6=96=87?= =?UTF-8?q?=E7=AB=A0id=E6=9F=A5=E6=89=BEusername=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/hellogithub/service/articleService.java | 7 ++++--- src/com/hellogithub/servlet/article/selectByArticleId.java | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/com/hellogithub/service/articleService.java b/src/com/hellogithub/service/articleService.java index c00ab5a..ab773f5 100644 --- a/src/com/hellogithub/service/articleService.java +++ b/src/com/hellogithub/service/articleService.java @@ -65,10 +65,11 @@ public class articleService { return JSONObject.toJSONString(dataMap1); } - public String selectByArticleId(int id){ + public String selectByArticleId(int articleid){ Map dataMap = new HashMap<>(); - articleEntity articleEntity = articleDao.selectByArticleId(id); - String username = userDao.selectNameById(id); + articleEntity articleEntity = articleDao.selectByArticleId(articleid); + int Userid = articleEntity.getUserId(); + String username = userDao.selectNameById(Userid); dataMap.put("ArticleContent",articleEntity.getArticleContent()); dataMap.put("ArticleId",articleEntity.getArticleId()); dataMap.put("ArticleTitle",articleEntity.getArticleTitle()); diff --git a/src/com/hellogithub/servlet/article/selectByArticleId.java b/src/com/hellogithub/servlet/article/selectByArticleId.java index c86b24a..3b6b05e 100644 --- a/src/com/hellogithub/servlet/article/selectByArticleId.java +++ b/src/com/hellogithub/servlet/article/selectByArticleId.java @@ -35,7 +35,7 @@ public class selectByArticleId extends HttpServlet { PrintWriter writer = resp.getWriter(); - String articleid = req.getParameter("id"); + String articleid = req.getParameter("articleid"); int id = Integer.parseInt(articleid); String jsonString = articleservice.selectByArticleId(id); if(jsonString == null){