From 38eb9a2a0afeeb373af4ad24fab985bfee37cd99 Mon Sep 17 00:00:00 2001 From: Qing Date: Thu, 6 Jul 2023 11:02:57 +0800 Subject: [PATCH] =?UTF-8?q?sql=E8=AF=AD=E5=8F=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/com/hellogithub/dao/projectDao.java | 2 +- src/com/hellogithub/servlet/selectByInputServlet.java | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/com/hellogithub/dao/projectDao.java b/src/com/hellogithub/dao/projectDao.java index 7bb7359..e7dbd9c 100644 --- a/src/com/hellogithub/dao/projectDao.java +++ b/src/com/hellogithub/dao/projectDao.java @@ -148,7 +148,7 @@ public class projectDao { try { Connection conn = JdbcUtils.getConnection(); QueryRunner runner = new QueryRunner(); - String sql = "SELECT * FROM project WHERE isValid = 1 and projectName LIKE %?%"; + String sql = "SELECT * FROM project WHERE isValid = 1 and projectTitle LIKE \"%\"? \"%\""; projectEntityList = runner.query(conn, sql, new BeanListHandler<>(projectEntity.class), str); conn.close(); } catch (SQLException e) { diff --git a/src/com/hellogithub/servlet/selectByInputServlet.java b/src/com/hellogithub/servlet/selectByInputServlet.java index b8b0737..2e4e095 100644 --- a/src/com/hellogithub/servlet/selectByInputServlet.java +++ b/src/com/hellogithub/servlet/selectByInputServlet.java @@ -45,7 +45,7 @@ public class selectByInputServlet extends HttpServlet { resp.setContentType("application/json;charset=UTF-8"); //添加搜索历史 PrintWriter writer = resp.getWriter(); - String str = req.getParameter("xxxxx"); + String str = req.getParameter("content"); List projectEntityList = projectService.selectByInput(str); HttpSession session = req.getSession(); @@ -59,7 +59,6 @@ public class selectByInputServlet extends HttpServlet { else{ String jsonString = JSONObject.toJSONString(projectEntityList); writer.println(jsonString); - setResultOK("success",writer); } } else{ @@ -72,7 +71,7 @@ public class selectByInputServlet extends HttpServlet { else{ String jsonString = JSONObject.toJSONString(projectEntityList); writer.println(jsonString); - setResultOK("success",writer); + writer.close(); } }