diff --git a/WebContent/admin/cardborrow.jsp b/WebContent/admin/cardborrow.jsp index ca00f39..3255d2e 100644 --- a/WebContent/admin/cardborrow.jsp +++ b/WebContent/admin/cardborrow.jsp @@ -1,6 +1,6 @@ <%@page import="javabean.Util"%> <%@page import="java.sql.PreparedStatement"%> -<%@page import="com.mysql.jdbc.Connection"%> +<%@page import="java.sql.Connection"%> <%@page import="javabean.Base"%> <%@page import="java.sql.ResultSet"%> <%@page import="javabean.JDBCBean"%> diff --git a/WebContent/manager/03borrowSus.jsp b/WebContent/manager/03borrowSus.jsp index 2815fc6..28588c5 100644 --- a/WebContent/manager/03borrowSus.jsp +++ b/WebContent/manager/03borrowSus.jsp @@ -135,7 +135,7 @@ }else{ %> <% diff --git a/WebContent/reader/index.jsp b/WebContent/reader/index.jsp index 3048d3f..0400a1d 100644 --- a/WebContent/reader/index.jsp +++ b/WebContent/reader/index.jsp @@ -98,7 +98,7 @@
状态: <% if(rs.getString("STATUS").equals("1")){ - out.println("正常"); + out.println("可用"); } else{ out.println("挂失"); diff --git a/src/servlet/admin/CardList.java b/src/servlet/admin/CardList.java index 592094f..bed1374 100644 --- a/src/servlet/admin/CardList.java +++ b/src/servlet/admin/CardList.java @@ -2,6 +2,7 @@ package servlet.admin; import java.io.IOException; import java.io.PrintWriter; +import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.ResultSet; import java.sql.SQLException; @@ -12,8 +13,6 @@ import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; -import java.sql.Connection; - import javabean.Base; import net.sf.json.JSONArray; import net.sf.json.JSONObject; @@ -25,19 +24,19 @@ import net.sf.json.JSONObject; public class CardList extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - resp.setContentType("application/json; charset:utf8"); + resp.setContentType("application/json; charset=utf8"); // 接收参数 String limit = req.getParameter("limit"); String page = req.getParameter("page"); - String condition = (String) req.getParameter("condition"); - String conditionValue = (String) req.getParameter("conditionValue"); - String where = null; // 无限制条件 - if(page == null) { - page = "1"; - } - if(limit == null) { - limit = "10"; - } + String condition = (String) req.getParameter("condition"); + String conditionValue = (String) req.getParameter("conditionValue"); + String where = null; // 无限制条件 + if (page == null) { + page = "1"; + } + if (limit == null) { + limit = "10"; + } Connection connection = null; PreparedStatement pstmt = null; ResultSet resultSet = null; @@ -45,7 +44,7 @@ public class CardList extends HttpServlet { String msg = "error"; int count = 0; String sql = ""; - //String countSql = "" + // String countSql = "" JSONObject jsonObject = new JSONObject(); JSONArray jsonArray = new JSONArray(); JSONObject jsonResult = new JSONObject(); @@ -54,20 +53,20 @@ public class CardList extends HttpServlet { connection = (Connection) Base.getConnection(); sql = "select id,password,reader,rule_id,status from borrow_card"; // where - if(condition != null && conditionValue != null && !condition.isEmpty() && !conditionValue.isEmpty()) { - where = " where "+ condition +" like '%" +conditionValue +"%'"; - sql = sql+where; - } + if (condition != null && conditionValue != null && !condition.isEmpty() && !conditionValue.isEmpty()) { + where = " where " + condition + " like '%" + conditionValue + "%'"; + sql = sql + where; + } // 分页 - sql +=" order by id desc limit ?,?"; + sql += " order by id desc limit ?,?"; pstmt = connection.prepareStatement(sql); try { - pstmt.setInt(1, (Integer.parseInt(page)-1) * Integer.parseInt(limit) ); + pstmt.setInt(1, (Integer.parseInt(page) - 1) * Integer.parseInt(limit)); pstmt.setInt(2, Integer.parseInt(limit)); } catch (NumberFormatException | SQLException e1) { } resultSet = pstmt.executeQuery(); - while(resultSet.next()) { + while (resultSet.next()) { jsonObject.put("id", resultSet.getString("id")); jsonObject.put("password", resultSet.getString("password")); jsonObject.put("reader", resultSet.getString("reader")); @@ -78,16 +77,16 @@ public class CardList extends HttpServlet { // 获取总数 sql = "select count(*) as count from borrow_card "; // 有限制 - if(where!=null) { - sql = sql+where; + if (where != null) { + sql = sql + where; } pstmt = connection.prepareStatement(sql); resultSet = pstmt.executeQuery(); - if(resultSet.next()) { + if (resultSet.next()) { count = resultSet.getInt("count"); } - - if(!jsonArray.isEmpty()) { + + if (!jsonArray.isEmpty()) { code = 0; msg = "成功"; } @@ -96,7 +95,7 @@ public class CardList extends HttpServlet { e.printStackTrace(); } catch (SQLException e) { msg = "sql错误"; - }finally { + } finally { try { Base.closeResource(connection, pstmt, resultSet); } catch (SQLException e) { @@ -109,7 +108,7 @@ public class CardList extends HttpServlet { jsonResult.put("data", jsonArray.toString()); PrintWriter out = resp.getWriter(); out.print(jsonResult.toString()); - //out.print("{\"code\":0,\"msg\":\"\",\"count\":\"234\",\"data\":[{\"id\":\"1\",\"password\":\"23442\",\"reader\":\"minm\",\"rule_id\":\"1\",\"status\":\"2\"}]}"); + // out.print("{\"code\":0,\"msg\":\"\",\"count\":\"234\",\"data\":[{\"id\":\"1\",\"password\":\"23442\",\"reader\":\"minm\",\"rule_id\":\"1\",\"status\":\"2\"}]}"); } } diff --git a/src/servlet/admin/SortList.java b/src/servlet/admin/SortList.java index e0e014e..f731e3e 100644 --- a/src/servlet/admin/SortList.java +++ b/src/servlet/admin/SortList.java @@ -18,14 +18,13 @@ import javabean.Util; import net.sf.json.JSONArray; import net.sf.json.JSONObject; - @WebServlet("/admin/sortList") public class SortList extends HttpServlet { @Override protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { - resp.setContentType("application/json; charset:utf8"); + resp.setContentType("application/json; charset=utf8"); // 接受参数 - + // 准备参数 Connection connection = null; PreparedStatement pstmt = null; @@ -44,16 +43,16 @@ public class SortList extends HttpServlet { sql = "select * from book_sort"; pstmt = connection.prepareStatement(sql); resultSet = pstmt.executeQuery(); - while(resultSet.next()) { + while (resultSet.next()) { jsonObject.put("id", resultSet.getString("id")); jsonObject.put("name", resultSet.getString("name")); jsonObject.put("description", resultSet.getString("description")); jsonArray.add(jsonObject.toString()); } - if(!jsonArray.isEmpty()) { + if (!jsonArray.isEmpty()) { code = 0; - msg = "查询成功"; - }else { + msg = "查询成功"; + } else { msg = "数据为空"; } } catch (ClassNotFoundException e) { @@ -61,15 +60,15 @@ public class SortList extends HttpServlet { e.printStackTrace(); } catch (SQLException e) { msg = "sql错误"; - }finally { + } finally { try { Base.closeResource(connection, pstmt, resultSet); } catch (SQLException e) { msg = "关闭失败"; } } - out.print( Util.jsonResponse(code, msg, jsonArray.toString()) ); - + out.print(Util.jsonResponse(code, msg, jsonArray.toString())); + } } diff --git a/src/servlet/reader/Book.java b/src/servlet/reader/Book.java index fa2e28b..2984b10 100644 --- a/src/servlet/reader/Book.java +++ b/src/servlet/reader/Book.java @@ -47,7 +47,7 @@ public class Book extends HttpServlet { String countSql = ""; // 准备返回参数 int code = 1; - String msg = "error"; + String msg = "无数据"; int count = 0; JSONObject jsonData = new JSONObject(); diff --git a/src/servlet/reader/Borrow.java b/src/servlet/reader/Borrow.java index 5d20ff7..a419b44 100644 --- a/src/servlet/reader/Borrow.java +++ b/src/servlet/reader/Borrow.java @@ -48,7 +48,7 @@ public class Borrow extends HttpServlet { String countSql = ""; // 准备返回参数 int code = 1; - String msg = "error"; + String msg = "无数据"; int count = 0; HttpSession session = req.getSession(); diff --git a/src/servlet/reader/Illegal.java b/src/servlet/reader/Illegal.java index 5217d59..fc8ad5e 100644 --- a/src/servlet/reader/Illegal.java +++ b/src/servlet/reader/Illegal.java @@ -48,7 +48,7 @@ public class Illegal extends HttpServlet { String countSql = ""; // 准备返回参数 int code = 1; - String msg = "error"; + String msg = "无数据"; int count = 0; HttpSession session = req.getSession();