国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

基于javaweb+mysql的jsp+servlet圖書圖書館管理系統(tǒng)(java+jsp+layui+bootstrap+servlet+mysql)

這篇具有很好參考價值的文章主要介紹了基于javaweb+mysql的jsp+servlet圖書圖書館管理系統(tǒng)(java+jsp+layui+bootstrap+servlet+mysql)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

基于javaweb+mysql的jsp+servlet圖書圖書館管理系統(tǒng)(java+jsp+layui+bootstrap+servlet+mysql)

運行環(huán)境

Java≥8、MySQL≥5.7、Tomcat≥8

開發(fā)工具

eclipse/idea/myeclipse/sts等均可配置運行

適用

課程設計,大作業(yè),畢業(yè)設計,項目練習,學習演示等

功能說明

基于javaweb+mysql的JSP+Servlet圖書圖書館管理系統(tǒng)(java+jsp+layui+bootstrap+servlet+mysql)

項目介紹

使用jsp+servlet、layui、mysql完成的圖書館系統(tǒng),包含用戶圖書借閱、圖書管理員、系統(tǒng)管理員界面,功能齊全。

開發(fā)工具為eclipse/IDEA,環(huán)境java8,tomcat9.0+,mysql為5.7(mysql8也行)

項目詳細介紹

本圖書管理系統(tǒng)總體上分為前臺頁面顯示和后臺管理。

前臺頁面(即本書圖書管理系統(tǒng)的首頁)實現(xiàn)了公告的顯示,圖書查詢,留言建議三大主要功能,有讀者規(guī)則查看功能,師生們可以看到圖書管理人員發(fā)布的最新公告信息,并可以查詢自己感興趣的圖書,查看留言提議,用戶登錄后還有個人資料修改、個人借閱信息查詢、個人違章信息查詢等功能,也可以給學校的圖書管理人員留言提議。

后臺的頁面則集成了圖書管理中所需的功能,分成圖書管理人員和系統(tǒng)管理人員,平時管理人員的工作都是在后臺中完成的。前臺是為了師生顯示的。相對應的后臺是針對學校圖書管理人員,后臺的頁面都加密,如果不正常登錄是進入不了后臺管理頁面的,后臺圖書管理人員功能包括:借閱圖書、歸還圖書、借書記錄顯示與查找、還書記錄顯示與查找、公告增刪改查;后臺系統(tǒng)管理員功能包括:對書籍的增刪改查、對書籍分類的增刪改、對借閱證的增刪改查、對借閱信息的顯示與查找、對借閱規(guī)則的增刪改、對圖書管理員的增刪改、對近期借閱書籍數(shù)量的折線圖顯示,以及對這些表格數(shù)據(jù)進行Excel表格的輸出

共包含三個大模塊:用戶、圖書管理員、系統(tǒng)管理員

一、用戶模塊

  1. 查看公告:能看到圖書管理員發(fā)布的公告信息。 2. 圖書查看:分頁顯示,能看到圖書總覽,能通過圖書編號、圖書名稱、作者、存放位置、圖書描述進行模糊查詢 3. 個人違章信息(登錄后):個人歷史違章信息與查詢 4. 圖書館讀者留言(登錄后):對圖書館的建議,或對書籍的評價 5. 查看借閱規(guī)則:不同的規(guī)則有不同的借閱限定數(shù)量、限定時間、超期費用 6. 個人信息(登錄后):對個人信息的查看與登錄密碼的修改 7. 個人借閱信息(登錄后):對個人借閱記錄的分頁查看與查詢

二、圖書管理員模塊

  1. 借還圖書:幫助用戶借閱圖書,并判斷符不符合借閱規(guī)則、返還圖書時判斷有沒有超期,超期則輸出超期費用再歸還 2. 借閱報表:分頁顯示所有借閱記錄、能進行查詢和輸出結果到excel公告管理:能添加編輯和刪除公告 3. 還書報表:分頁顯示所有未還的書籍,能通過借閱證號、圖書編號、借閱日期、截止日期等條件進行模糊查詢 4. 個人信息修改:修改個人信息、密碼等

三、系統(tǒng)管理員模塊

  1. 書籍管理:分頁,新添圖書,設置圖書各種信息,編輯刪除,通過編號、書名、作者、描述等進行搜索,輸出結果到excel,并且能查看該書籍被誰借閱過。 2. 分類管理:分頁顯示,增刪改書籍分類,書籍分類方便查閱整理 3. 借閱證管理:分頁顯示所有借閱證,增刪改查用戶借閱證,查看該借閱證所有的借閱記錄 4. 借閱規(guī)則管理:能顯示、編輯、刪除所有借閱規(guī)則,借閱規(guī)則將決定該圖書證能借閱什么圖書館的圖書,能借多少本,能借多久以及超期每天的費用。 5. 借閱信息查詢:分頁顯示,能條件查詢超期沒還的,根據(jù)編號、借閱證號、書籍編號、借閱日期等進行模糊查詢,輸出結果到excel等,系統(tǒng)管理員只能查詢,不能增刪改借閱信息,這個操作由圖書管理員操作。 6. 圖書管理員管理:對圖書管理員進行增刪改操作,但是不能修改原來的賬號 7. 圖書借閱統(tǒng)計:通過折線圖將圖書館近30天的每天借閱書籍數(shù)量直觀的顯示出來。

sql表

共有十張數(shù)據(jù)庫表,書籍表、借書記錄表、留言表、系統(tǒng)管理員表、借閱證表、圖書管理管理員表書籍分類表、圖書館表、借閱規(guī)則表、公告表 - 書籍表 - 編號、姓名、作者、存放的圖書館、分類編號、存放位置、是否借出、書籍描述 - 借書記錄表 - 編號、借閱證編號、書籍編號、借書日期、限制日期、歸還日期、違規(guī)描述、處理人編號 - 留言表 - 編號、借閱證編號、留言內(nèi)容、留言日期 - 系統(tǒng)管理員表 - 賬號、密碼 - 借閱證表 - 編號、密碼、借閱者姓名、規(guī)則編號、狀態(tài)(丟失、可用) - 圖書管理員表 - 編號、姓名、賬號、密碼、郵箱 - 書籍分類表 - 編號、分類名、分類描述 - 圖書館表 - 編號、圖書館名、描述 - 規(guī)則表 - 編號、限制借閱數(shù)量、限制借閱天數(shù)、圖書超期每天費用 - 公告表 - 編號、標題、公告內(nèi)容、發(fā)布日期

環(huán)境需要

1.運行環(huán)境:最好是java jdk 1.8,我們在這個平臺上運行的。其他版本理論上也可以。 2.IDE環(huán)境:IDEA,Eclipse,Myeclipse都可以。推薦IDEA; 3.tomcat環(huán)境:Tomcat 9.x版本,注:tomcat9.0以下會有問題; 4.硬件環(huán)境:windows 7/8/10 1G內(nèi)存以上;或者 Mac OS; 5.是否Maven項目: 否;查看源碼目錄中是否包含pom.xml;若包含,則為maven項目,否則為非maven項目 6.數(shù)據(jù)庫:MySql 5.7版本,(mysql8也行)

技術棧

  1. 后端:JSP+Servlet 2. 前端:jsp+layui+bootstrap+jQuery

使用說明

  1. 使用Navicat或者其它工具,在mysql中創(chuàng)建對應名稱的數(shù)據(jù)庫,并導入項目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse導入項目,Eclipse/MyEclipse導入時,若為maven項目請選擇maven;若為maven項目,導入成功后請執(zhí)行maven clean;maven install命令,配置tomcat,然后運行; 3. 將項目中src/javabean/Base.java和JDBCBean.java配置文件中的數(shù)據(jù)庫配置改為自己的配置; 4. 運行項目,輸入localhost:8080/xxx 登錄 5. 用戶賬號密碼:1805010219 1234 圖書管理員賬號密碼:root 1234 系統(tǒng)管理員賬號密碼:admin admin
			resultSet = pstmt.executeQuery();
			while (resultSet.next()) {

				String library = resultSet.getString("library_id");
				String sql1 = "select * from library where ID =" + library;
				PreparedStatement pstmt1 = connection.prepareStatement(sql1);
				ResultSet rs1 = pstmt1.executeQuery();
				String lib = "";
				while (rs1.next()) {
					lib = rs1.getString("name");
				}

				String sortid = resultSet.getString("sort_id");
				String sql2 = "select * from book_sort where ID =" + sortid;
				PreparedStatement pstmt2 = connection.prepareStatement(sql2);
				ResultSet rs2 = pstmt2.executeQuery();
				String sort = "";
				while (rs2.next()) {
					sort = rs2.getString("name");
				}

				jsonData.put("id", resultSet.getString("id"));
				jsonData.put("name", resultSet.getString("name"));
				jsonData.put("author", resultSet.getString("author"));
				jsonData.put("library_id", lib);
				jsonData.put("sort_id", sort);
				jsonData.put("position", resultSet.getString("position"));
				jsonData.put("status", resultSet.getString("status"));
				jsonData.put("description", resultSet.getString("description"));
				jsonArray.add(jsonData);
			}
			countSql = "select count(*) as count from books ";
			countSql += where;
			countPstmt = connection.prepareStatement(countSql);
			countSet = countPstmt.executeQuery();
			if (countSet.next()) {
				count = countSet.getInt("count");
			}
			if (!jsonArray.isEmpty()) {
				code = 0;
				msg = "查詢成功";
			}

		} catch (ClassNotFoundException e) {
			msg = "class沒找到";
		} catch (SQLException e) {
			msg = "sql錯誤";
				pstmt1 = connection1.prepareStatement(findIdSql);
				pstmt1.setString(1, password);
				pstmt1.setString(2, reader);
				pstmt1.setString(3, rule_id);
				pstmt1.setString(4, status);
				dataSet = pstmt1.executeQuery();
				if(dataSet.next()) {
					jsonData.put("id", dataSet.getString("id"));
				}
			} catch (ClassNotFoundException e) {
				msg = "發(fā)生異常";
			} catch (SQLException e) {
				msg = "sql錯誤";
				System.out.println("sql失敗");
			} 
			try {
				Base.closeResource(connection, pstmt, null);
				Base.closeResource(connection1, pstmt1, dataSet);
			} catch (SQLException e) {
				msg = "關閉資源失敗";
			}
			if(result == 1 && !jsonData.isNullObject() && !jsonData.isEmpty()) {
				System.out.println(jsonData.toString());  //debug
				code = "0";
				msg = "添加成功";
			}else {
				code = "1";
				msg = "執(zhí)行失敗";
			}
		}
		json.put("code", code);
		json.put("msg", msg);
		json.put("data", jsonData.toString());
		PrintWriter out = resp.getWriter();
		out.print(json.toString());
	}

}
package servlet.admin;

 * Servlet implementation class ReturnTable
 */
@WebServlet("/manager1/returnTable")
public class ReturnTable extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 接收參數(shù)
		String limit = req.getParameter("limit");
		String page = req.getParameter("page");
		String condition = (String) req.getParameter("condition");
		String conditionValue = (String) req.getParameter("conditionValue");
		String where = ""; // 無限制條件
		if (page == null) {
			page = "1";
		}
		if (limit == null) {
			limit = "10";
		}
		// 準備查詢
		Connection connection = null;
		PreparedStatement pstmt = null;
		PreparedStatement countPstmt = null;
		ResultSet resultSet = null;
		ResultSet countSet = null;
		String sql = "";
		String countSql = "";
		// 準備返回參數(shù)
		int code = 1;
		String msg = "無數(shù)據(jù)";
		int count = 0;

		JSONObject jsonData = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		JSONObject jsonResult = new JSONObject();
		// 進行查詢
		try {
			connection = (Connection) Base.getConnection();
			sql = "select * from borrow_books where manager_id is null";
			if (condition != null && conditionValue != null && !condition.equals("") && !conditionValue.equals("")) {

@WebServlet("/admin/ruleAdd")
public class RuleAdd extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 準備數(shù)據(jù)
		Connection connection = null;
		PreparedStatement pstmt = null;
		ResultSet resultSet = null;
		int result = 0;
		String sql = "";
		String borrow_library = "";
		
		// 準備返回數(shù)據(jù)
		int code = 1;
		String msg = "";
		
		// 獲取數(shù)據(jù)
		// 獲取限定圖書館1、2、3
		int num = 0;
		try {
			Map<String, String> libraryMap = Common.getLibraryMap();
			for(String key : libraryMap.keySet()) {
				if(req.getParameter("borrow_library[" +key +"]") != null) {
					if(num == 0) {
						borrow_library += key;
						num++;
					}else {
						borrow_library += "、"+key;
					}
				}
			}
        String regEx_html = "<[^>]+>"; // 定義HTML標簽的正則表達式 
         
        Pattern p_script = Pattern.compile(regEx_script,Pattern.CASE_INSENSITIVE); 
        Matcher m_script = p_script.matcher(htmlStr); 
        htmlStr=m_script.replaceAll(""); // 過濾script標簽 
         
        Pattern p_style=Pattern.compile(regEx_style,Pattern.CASE_INSENSITIVE); 
        Matcher m_style=p_style.matcher(htmlStr); 
        htmlStr=m_style.replaceAll(""); // 過濾style標簽 
         
        Pattern p_html=Pattern.compile(regEx_html,Pattern.CASE_INSENSITIVE); 
        Matcher m_html=p_html.matcher(htmlStr); 
        htmlStr=m_html.replaceAll(""); // 過濾html標簽 
 
        return htmlStr.trim(); // 返回文本字符串 
    } 
	/**
     * 一般使用ServletRequest對象獲取表單提交的數(shù)據(jù),
     * (主要通過 getParameter() 和 getParameterValues()
     * 方法獲取),再此創(chuàng)建內(nèi)部類Request,重寫getParameter()
     * 和 getParameterValues(),并在重寫的兩個方法中實現(xiàn)過濾 
     */

    class Request extends HttpServletRequestWrapper{// HttpServletRequest                                                                      //Wrapper是servletRequest的實現(xiàn)類

        public Request(HttpServletRequest request) {
            super(request);
        }

        @Override
        public String getParameter(String name) {
            // 返回過濾后的參數(shù)值
            return filter(super.getRequest().getParameter(name));
        }

        @Override
        public String[] getParameterValues(String name) {
            // 獲取所有參數(shù)值
            String[] values = super.getRequest().getParameterValues(name);
            // 通過循環(huán)對所有參數(shù)進行進行過濾
            for(int i=0;i<values.length;i++){
                values[i] = filter(values[i]);
            }
            return values;
        }

    }

			countSql += where;
			countPstmt = connection.prepareStatement(countSql);
			countSet = countPstmt.executeQuery();
			if (countSet.next()) {
				count = countSet.getInt("count");
			}
			if (!jsonArray.isEmpty()) {
				code = 0;
				msg = "查詢成功";
			}

		} catch (ClassNotFoundException e) {
			msg = "class沒找到";
		} catch (SQLException e) {
			msg = "sql錯誤";
		} finally {
			try {
				Base.closeResource(null, pstmt, resultSet);
				Base.closeResource(connection, countPstmt, countSet);
			} catch (SQLException e) {
				msg = "關閉資源失敗";
			}

		}
		// 返回數(shù)據(jù)
		jsonResult.put("code", code);
		jsonResult.put("count", count);
		jsonResult.put("msg", msg);
		jsonResult.put("data", jsonArray.toArray());
		PrintWriter out = resp.getWriter();
		out.print(jsonResult.toString());
	}

}
package servlet.manager;

		String position = req.getParameter("position");
		String status = req.getParameter("status");
		String description = req.getParameter("description");
		System.out.println(description+"-------------");
		JSONObject json = new JSONObject();
		//if(id == null || id.equals(""))
		Connection connection = null;
		PreparedStatement pstmt = null;
		//ResultSet resultSet = null;
		int result = 0;
		String sql = "update books set name=? ,author=? ,library_id=? ,sort_id=? ,position=? ,status=?, description=? where id=?";
		PrintWriter out = resp.getWriter();
		try {
			connection = (Connection) Base.getConnection();
			pstmt = connection.prepareStatement(sql);
			pstmt.setString(1, name);
			pstmt.setString(2, author);
			pstmt.setString(3, library_id);
			pstmt.setString(4, sort_id);
			pstmt.setString(5, position);
			pstmt.setString(6, status);
			pstmt.setString(7, description);
			pstmt.setString(8, id);
			result = pstmt.executeUpdate();
		} catch (SQLException e) {
			
		} catch (ClassNotFoundException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}finally {
			try {
				Base.closeResource(connection, pstmt, null);
			} catch (SQLException e) {
				e.printStackTrace();
			}
		}
		if(result==1) {
			json.put("code", "0");
			json.put("msg", "success");
		}else {
			json.put("code", "1");
			json.put("msg", "error");
		}
		out.write(json.toString());
		
		
		 
		
		//System.out.println(postData);
		//JSONObject json = JSONObject.fromObject();
	}
				count = countSet.getInt("count");
			}
			if (!jsonArray.isEmpty()) {
				code = 0;
				msg = "查詢成功";
			}

		} catch (ClassNotFoundException e) {
			msg = "class沒找到";
		} catch (SQLException e) {
			msg = "sql錯誤";
		} finally {
			try {
				Base.closeResource(null, pstmt, resultSet);
				Base.closeResource(connection, countPstmt, countSet);
			} catch (SQLException e) {
				msg = "關閉資源失敗";
			}

		}
		// 返回數(shù)據(jù)
		jsonResult.put("code", code);
		jsonResult.put("count", count);
		jsonResult.put("msg", msg);
		jsonResult.put("data", jsonArray.toArray());
		PrintWriter out = resp.getWriter();
		out.print(jsonResult.toString());
	}

}
package servlet.manager;

		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;
		int code = 1;
		String msg = "error";
		int count = 0;
		String sql = "";
		// String countSql = ""
		JSONObject jsonObject = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		JSONObject jsonResult = new JSONObject();
		try {
			// 獲取數(shù)據(jù)
			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;
			}
			// 分頁
			sql += "  order by id desc limit ?,?";
			pstmt = connection.prepareStatement(sql);
			try {
				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()) {
				jsonObject.put("id", resultSet.getString("id"));
				jsonObject.put("password", resultSet.getString("password"));
				jsonObject.put("reader", resultSet.getString("reader"));
				jsonObject.put("rule_id", resultSet.getString("rule_id"));
				jsonObject.put("status", resultSet.getString("status"));
				jsonArray.add(jsonObject);
			}
			// 獲取總數(shù)
			sql = "select count(*) as count from borrow_card ";
}
package servlet.admin;

@WebServlet("/admin/cardDel")
public class CardDel extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 接收數(shù)據(jù)
		String id = req.getParameter("id");
		// 處理數(shù)據(jù)
		Connection connection = null;
		PreparedStatement delCardPstmt = null;
		PreparedStatement delHistoryPstmt = null;
		String delCardSql = null;
		String delHistorySql = null;
		int delCardResult = 0;
		int delHistoryResult = 0;
		// 返回數(shù)據(jù)
		String code = "1";
		String msg = "error";
		JSONObject jsonObject = new JSONObject();
		JSONObject jsonData = new JSONObject();
		// 開始處理
		if(id != null && !id.equals("")) {
			try {
				// 公共連接
				connection = (Connection) Base.getConnection();
				// 刪除借書記錄
				delHistorySql = "delete from borrow_books where card_id=?";
				delHistoryPstmt = connection.prepareStatement(delHistorySql);
				delHistoryPstmt.setString(1, id);
            // 獲取所有參數(shù)值
            String[] values = super.getRequest().getParameterValues(name);
            // 通過循環(huán)對所有參數(shù)進行進行過濾
            for(int i=0;i<values.length;i++){
                values[i] = filter(values[i]);
            }
            return values;
        }

    }

    /**
     * @see Filter#doFilter(ServletRequest, ServletResponse, FilterChain)
     */
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
        /*if(encoding != null){
            request.setCharacterEncoding(encoding);
            //將request替換為重寫后的request
            request = new Request((HttpServletRequest) request);
            response.setContentType("text/html; charset = "+encoding);
        }*/
    	request = new Request((HttpServletRequest) request);
        chain.doFilter(request, response);
    }

    /**
     * @see Filter#destroy()
     */
    public void destroy() {
    }

}
package servlet.admin;

	
    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
    	doGet(req, resp);
    }
}               
package servlet.admin;

@WebServlet("/admin/cardEdit")
public class CardEdit extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 接受數(shù)據(jù)
		String id = req.getParameter("id");
		String password = req.getParameter("password");
		String reader = req.getParameter("reader");
		String rule_id = req.getParameter("rule_id");
		String status = req.getParameter("status");
		// 準備資源
		Connection connection = null;
		PreparedStatement pstmt = null;
		ResultSet resultSet = null;
		int result = 0;
		String sql = null;
		String msg = "error";
		JSONObject jsonObject = new JSONObject();
		JSONObject jsonData = new JSONObject();
		// 開始處理
		if(id != null && !id.equals("")) {
			try {
				// 公共連接
				connection = (Connection) Base.getConnection();
				// 刪除借書記錄
				delHistorySql = "delete from borrow_books where card_id=?";
				delHistoryPstmt = connection.prepareStatement(delHistorySql);
				delHistoryPstmt.setString(1, id);
				delHistoryResult = delHistoryPstmt.executeUpdate();
				// 返回刪除記錄條數(shù)
				jsonData.put("num", delHistoryResult);
				// 刪除閱讀證
				delCardSql = "delete from borrow_card where id=? limit 1";
				delCardPstmt = connection.prepareStatement(delCardSql);
				delCardPstmt.setString(1, id);
				delCardResult = delCardPstmt.executeUpdate();
				
			} catch (ClassNotFoundException e) {
				msg = "連接失敗";
			} catch (SQLException e) {
				msg = "sql錯誤";
			} finally {
				try {
					delCardPstmt.close();
					Base.closeResource(connection, delCardPstmt, null);
				} catch (SQLException e) {
					msg = "關閉失敗";
				}
			}
		}
		PrintWriter out = resp.getWriter();
		if(delCardResult == 1) {
			code = "0";
			msg = "刪除借閱證成功";
		}
		jsonObject.put("code", code);
		jsonObject.put("msg", msg);
		jsonObject.put("data", jsonData);
		out.print(jsonObject.toString());
	}
			limit = "10";
		}
		// 準備查詢
		Connection connection = null;
		PreparedStatement pstmt = null;
		PreparedStatement countPstmt = null;
		ResultSet resultSet = null;
		ResultSet countSet = null;
		String sql = "";
		String countSql = "";
		// 準備返回參數(shù)
		int code = 1;
		String msg = "無數(shù)據(jù)";
		int count = 0;

		JSONObject jsonData = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		JSONObject jsonResult = new JSONObject();
		// 進行查詢
		try {
			connection = (Connection) Base.getConnection();
			sql = "select * from borrow_books where manager_id is not null";
			if (condition != null && conditionValue != null && !condition.equals("") && !conditionValue.equals("")) {
				where = " and " + condition + " like '%" + conditionValue + "%' ";
				sql += where;
			}
			sql += " limit ?,?";// 1 10 (1-1)*10
			System.out.println("???" + sql);
			pstmt = connection.prepareStatement(sql);
			pstmt.setInt(1, (Integer.parseInt(page) - 1) * Integer.parseInt(limit));
			pstmt.setInt(2, Integer.parseInt(limit));
			resultSet = pstmt.executeQuery();
			while (resultSet.next()) {
				jsonData.put("id", resultSet.getString("id"));
				jsonData.put("card_id", resultSet.getString("card_id"));
				jsonData.put("book_id", resultSet.getString("book_id"));
				jsonData.put("borrow_date", resultSet.getString("borrow_date"));
				jsonData.put("end_date", resultSet.getString("end_date"));
				jsonData.put("return_date", resultSet.getString("return_date"));
				jsonData.put("illegal", resultSet.getString("illegal"));
				jsonData.put("manager_id", resultSet.getString("manager_id"));
				jsonArray.add(jsonData);
			}
			countSql = "select count(*) as count from borrow_books where manager_id is not null";
				jsonData.put("book_id", resultSet.getString("book_id"));
				jsonData.put("borrow_date", resultSet.getString("borrow_date"));
				jsonData.put("end_date", resultSet.getString("end_date"));

				jsonArray.add(jsonData);
			}
			countSql = "select count(*) as count from borrow_books where manager_id is null";
			countSql += where;
			countPstmt = connection.prepareStatement(countSql);
			countSet = countPstmt.executeQuery();
			if (countSet.next()) {
				count = countSet.getInt("count");
			}
			if (!jsonArray.isEmpty()) {
				code = 0;
				msg = "查詢成功";
			}

		} catch (ClassNotFoundException e) {
			msg = "class沒找到";
		} catch (SQLException e) {
			msg = "sql錯誤";
		} finally {
			try {
				Base.closeResource(null, pstmt, resultSet);
				Base.closeResource(connection, countPstmt, countSet);
			} catch (SQLException e) {
				msg = "關閉資源失敗";
			}

		}
		// 返回數(shù)據(jù)
		jsonResult.put("code", code);
		jsonResult.put("count", count);
		jsonResult.put("msg", msg);
		jsonResult.put("data", jsonArray.toArray());
		PrintWriter out = resp.getWriter();
		out.print(jsonResult.toString());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			msg = "class沒找到";
		} catch (SQLException e) {
			msg = "sql錯誤";
		} finally {
			try {
				Base.closeResource(null, pstmt, resultSet);
				Base.closeResource(connection, countPstmt, countSet);
			} catch (SQLException e) {
				msg = "關閉資源失敗";
			}
			
		}
		// 返回數(shù)據(jù)
		jsonResult.put("code", code);
		jsonResult.put("count", count);
		jsonResult.put("msg", msg);
		jsonResult.put("data", jsonArray.toArray());
		PrintWriter out = resp.getWriter();
		out.print(jsonResult.toString());
	}
       
     

}
package servlet.reader;

/**
 * Servlet implementation class Illegal
 */
@WebServlet("/reader/illegal")
public class Illegal extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
			result = pstmt.executeUpdate();
			if(result == 1) {
				code = 0;
				msg = "success";
			}
		} catch (ClassNotFoundException e) {
			msg = "classnotfound";
		} catch (SQLException e) {
			msg = "SQL錯誤";
		} finally {
			try {
				Base.closeResource(connection, pstmt, null);
			} catch (SQLException e) {
				msg = "關閉失敗";
			}
		}
		
		PrintWriter out = resp.getWriter();
		out.print(Util.jsonResponse(code, msg, null));
		
	}

}
package servlet.admin;

@WebServlet("/admin/cardDel")
public class CardDel extends HttpServlet {
		}
		String borrow_num = req.getParameter("borrow_num");
		String limit_day = req.getParameter("limit_day");
		String overtime_fee = req.getParameter("overtime_fee");
		try {
			connection = (Connection) Base.getConnection();
			sql = "insert into rules(borrow_num, limit_day, borrow_library, overtime_fee) values(?,?,?,?)";
			pstmt = connection.prepareStatement(sql);
			pstmt.setString(1, borrow_num);
			pstmt.setString(2, limit_day);
			pstmt.setString(3, borrow_library);
			pstmt.setString(4, overtime_fee);
			result = pstmt.executeUpdate();
			if(result == 1) {
				code = 0;
				msg = "success";
			}
		} catch (ClassNotFoundException e) {
			msg = "classnotfound";
		} catch (SQLException e) {
			msg = "SQL錯誤";
		} finally {
			try {
				Base.closeResource(connection, pstmt, null);
			} catch (SQLException e) {
				msg = "關閉失敗";
			}
		}
		
		PrintWriter out = resp.getWriter();
		out.print(Util.jsonResponse(code, msg, null));
		
	}

}
package servlet.admin;

		JSONObject json = new JSONObject();
		PrintWriter out = resp.getWriter();
		// 判斷數(shù)據(jù)
		if(id == null || password == null || reader == null || reader == null || status == null || 
				id.equals("") || password.equals("") || reader.equals("") || rule_id.equals("") || status.equals("")) {
			code = "1";
			msg = "參數(shù)不能為空";
		}else {
			sql = "update borrow_card set password=?, reader=?, rule_id=?, status=? where id=?";
			try {
				connection = (Connection) Base.getConnection();
				pstmt = connection.prepareStatement(sql);
				pstmt.setString(1, password);
				pstmt.setString(2, reader);
				pstmt.setString(3, rule_id);
				pstmt.setString(4, status);
				pstmt.setString(5, id);
				result = pstmt.executeUpdate();
			} catch (ClassNotFoundException e1) {
				msg = "錯誤";
			} catch (SQLException e) {
				msg = "sql錯誤";
			} finally {
				try {
					Base.closeResource(connection, pstmt, resultSet);
				} catch (SQLException e) {
					msg = "關閉失敗";
				}
			}
			if(result == 1) {
				code = "0";
				msg = "修改成功";
			}
			json.put("code", code);
			json.put("msg", msg);
			out.print(json.toString());
		}
	}	

}
package servlet.admin;

			}
			
		}
		// 返回數(shù)據(jù)
		jsonResult.put("code", code);
		jsonResult.put("count", count);
		jsonResult.put("msg", msg);
		jsonResult.put("data", jsonArray.toArray());
		PrintWriter out = resp.getWriter();
		out.print(jsonResult.toString());
	}
       
     

}
package servlet.reader;

/**
 * Servlet implementation class Illegal
 */
@WebServlet("/reader/illegal")
public class Illegal extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 接收參數(shù)
		String limit = req.getParameter("limit");
		String page = req.getParameter("page");
		String condition = (String) req.getParameter("condition");
		String conditionValue = (String) req.getParameter("conditionValue");
		String where = ""; // 無限制條件
		if (page == null) {
			page = "1";
		}
		// 準備返回參數(shù)
		int code = 1;
		String msg = "無數(shù)據(jù)";
		int count = 0;

		HttpSession session = req.getSession();

		JSONObject jsonData = new JSONObject();
		JSONArray jsonArray = new JSONArray();
		JSONObject jsonResult = new JSONObject();
		// 進行查詢
		try {
			connection = (Connection) Base.getConnection();
			sql = "select * from borrow_books where card_id = " + session.getAttribute("reader");
			if (condition != null && conditionValue != null && !condition.equals("") && !conditionValue.equals("")) {
				where = " and " + condition + " like '%" + conditionValue + "%' ";
				sql += where;
			}
			sql += " limit ?,?";// 1 10 (1-1)*10
			System.out.println("???" + sql);
			pstmt = connection.prepareStatement(sql);
			pstmt.setInt(1, (Integer.parseInt(page) - 1) * Integer.parseInt(limit));
			pstmt.setInt(2, Integer.parseInt(limit));
			resultSet = pstmt.executeQuery();
			while (resultSet.next()) {
				jsonData.put("id", resultSet.getString("id"));
				jsonData.put("card_id", resultSet.getString("card_id"));
				jsonData.put("book_id", resultSet.getString("book_id"));
				jsonData.put("borrow_date", resultSet.getString("borrow_date"));
				jsonData.put("end_date", resultSet.getString("end_date"));
				jsonData.put("return_date", resultSet.getString("return_date"));
				jsonArray.add(jsonData);
			}
			countSql = "select count(*) as count from borrow_books where card_id = "
					+ req.getSession().getAttribute("reader");
			countSql += where;
			countPstmt = connection.prepareStatement(countSql);
			countSet = countPstmt.executeQuery();
			if (countSet.next()) {
				count = countSet.getInt("count");
		} catch (SQLException e) {
			msg = "sql錯誤";
		} finally {
			try {
				Base.closeResource(null, pstmt, resultSet);
				Base.closeResource(connection, countPstmt, countSet);
			} catch (SQLException e) {
				msg = "關閉資源失敗";
			}

		}
		// 返回數(shù)據(jù)
		jsonResult.put("code", code);
		jsonResult.put("count", count);
		jsonResult.put("msg", msg);
		jsonResult.put("data", jsonArray.toArray());
		PrintWriter out = resp.getWriter();
		out.print(jsonResult.toString());
	}

}
package servlet.manager;

@WebServlet("/manager1/borrowTable")

@WebServlet("/admin/borrowList")
public class BorrowList extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 接收參數(shù)
		String limit = req.getParameter("limit");
		String page = req.getParameter("page");
    	String condition = (String) req.getParameter("condition");
    	String conditionValue = (String) req.getParameter("conditionValue");
    	String where = ""; // 無限制條件
		if(page == null) {
    		page = "1";
    	}
    	if(limit == null) {
    		limit = "10";
    	}
    	// 準備查詢
		Connection connection = null;
		PreparedStatement pstmt = null;
		PreparedStatement countPstmt = null;
		ResultSet resultSet = null;
		ResultSet countSet = null;
		String sql = "";
		String countSql = "";
		// 準備返回參數(shù)
		int code = 1;
		String msg = "error";
		int count = 0;
				jsonObject.put("id", resultSet.getString("id"));
				jsonObject.put("password", resultSet.getString("password"));
				jsonObject.put("reader", resultSet.getString("reader"));
				jsonObject.put("rule_id", resultSet.getString("rule_id"));
				jsonObject.put("status", resultSet.getString("status"));
				jsonArray.add(jsonObject);
			}
			// 獲取總數(shù)
			sql = "select count(*) as count from borrow_card ";
			// 有限制
			if (where != null) {
				sql = sql + where;
			}
			pstmt = connection.prepareStatement(sql);
			resultSet = pstmt.executeQuery();
			if (resultSet.next()) {
				count = resultSet.getInt("count");
			}

			if (!jsonArray.isEmpty()) {
				code = 0;
				msg = "成功";
			}
		} catch (ClassNotFoundException e) {
			msg = "沒找到";
			e.printStackTrace();
		} catch (SQLException e) {
			msg = "sql錯誤";
		} finally {
			try {
				Base.closeResource(connection, pstmt, resultSet);
			} catch (SQLException e) {
				msg = "關閉失敗";
			}
		}
		jsonResult.put("code", code);
		jsonResult.put("count", count);
		jsonResult.put("msg", msg);
		jsonResult.put("data", jsonArray.toString());
		PrintWriter out = resp.getWriter();
@WebServlet("/admin/cardAdd")
public class CardAdd extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 獲取參數(shù)
		String reader = req.getParameter("reader");
		String password = req.getParameter("password");
		String rule_id = req.getParameter("rule_id");
		String status = req.getParameter("status");
		// 準備資源
		String code = "1";
		String msg = "error";
		String data = "";
		JSONObject json = new JSONObject();
		JSONObject jsonData = new JSONObject();
		Connection connection = null;
		Connection connection1 = null;
		PreparedStatement pstmt = null;
		PreparedStatement pstmt1 = null;
		String sql = null;
		int result = 0;
		ResultSet dataSet = null;
		// 參數(shù)不能為空
		if(reader == null || password == null || rule_id == null || rule_id == null || status == null) {
			code = "1";
			msg = "值不能為空";
		}else {
			try {
				connection = (Connection) Base.getConnection();
				sql = "insert into borrow_card(password, reader, rule_id, status) values(?,?,?,?)";
				pstmt = connection.prepareStatement(sql);
				pstmt.setString(1, password);
				pstmt.setString(2, reader);
				pstmt.setString(3, rule_id);
				pstmt.setString(4, status);
				result = pstmt.executeUpdate();
				
				//獲取id
				connection1= (Connection) Base.getConnection();
				code = 0;
				msg = "查詢成功";
			}

		} catch (ClassNotFoundException e) {
			msg = "class沒找到";
		} catch (SQLException e) {
			msg = "sql錯誤";
		} finally {
			try {
				Base.closeResource(null, pstmt, resultSet);
				Base.closeResource(connection, countPstmt, countSet);
			} catch (SQLException e) {
				msg = "關閉資源失敗";
			}

		}
		// 返回數(shù)據(jù)
		jsonResult.put("code", code);
		jsonResult.put("count", count);
		jsonResult.put("msg", msg);
		jsonResult.put("data", jsonArray.toArray());
		PrintWriter out = resp.getWriter();
		out.print(jsonResult.toString());
	}

}
package servlet.admin;

			}

		} catch (ClassNotFoundException e) {
			msg = "class沒找到";
		} catch (SQLException e) {
			msg = "sql錯誤";
		} finally {
			try {
				Base.closeResource(null, pstmt, resultSet);
				Base.closeResource(connection, countPstmt, countSet);
			} catch (SQLException e) {
				msg = "關閉資源失敗";
			}

		}
		// 返回數(shù)據(jù)
		jsonResult.put("code", code);
		jsonResult.put("count", count);
		jsonResult.put("msg", msg);
		jsonResult.put("data", jsonArray.toArray());
		PrintWriter out = resp.getWriter();
		out.print(jsonResult.toString());
	}

}
package servlet.admin;

@WebServlet("/admin/borrowList")
public class BorrowList extends HttpServlet {
	@Override

圖書管理器jsp servlet,mysql,java,servlet

圖書管理器jsp servlet,mysql,java,servlet
圖書管理器jsp servlet,mysql,java,servlet
圖書管理器jsp servlet,mysql,java,servlet
圖書管理器jsp servlet,mysql,java,servlet
圖書管理器jsp servlet,mysql,java,servlet
文章來源地址http://www.zghlxwxcb.cn/news/detail-764415.html

到了這里,關于基于javaweb+mysql的jsp+servlet圖書圖書館管理系統(tǒng)(java+jsp+layui+bootstrap+servlet+mysql)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。如若轉載,請注明出處: 如若內(nèi)容造成侵權/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領支付寶紅包贊助服務器費用

相關文章

  • MySQL數(shù)據(jù)庫期末項目 圖書館管理系統(tǒng)

    MySQL數(shù)據(jù)庫期末項目 圖書館管理系統(tǒng)

    1 項目需求分析 1.1 項目名稱 圖書館管理系統(tǒng) 1.2 項目功能 在以前大多部分圖書館都是由人工直接管理,其中每天的業(yè)務和操作流程非常繁瑣復雜,紙質版的登記信息耗費了大量的人力物力。因此圖書館管理系統(tǒng)應運而生,該系統(tǒng)采用智能化設計,在業(yè)務流程的實現(xiàn)方面更加

    2023年04月18日
    瀏覽(21)
  • 【C#項目】圖書館管理系統(tǒng)-WinForm+MySQL

    【C#項目】圖書館管理系統(tǒng)-WinForm+MySQL

    圖書館管理系統(tǒng)主要功能有普通用戶(學生)借書、管理員管理圖書。 1.功能描述 系統(tǒng)中的普通用戶模塊有以下功能: 圖書查詢:根據(jù)輸入的搜索條件進行查詢,可以查找多項,也可以查找所有圖書。 圖書借閱:提供圖書借閱證號,可以進行圖書借閱。 系統(tǒng)中的管理員用戶

    2024年02月02日
    瀏覽(33)
  • 基于Python的圖書館管理系統(tǒng)的開發(fā)

    基于Python的圖書館管理系統(tǒng)的開發(fā)

    開發(fā)工具: python3.10 數(shù)據(jù)庫: Python內(nèi)置的SQLite3數(shù)據(jù)庫,SQLite是一種嵌入式數(shù)據(jù)庫,體積很小,它的數(shù)據(jù)庫就是一個文件。本文 建立了Library數(shù)據(jù)庫,存儲系統(tǒng)內(nèi)的管理員、圖書、讀者、借閱相關信息。 ????????傳統(tǒng)人工方式管理文件檔案存在著許多缺點,如:效率低、保

    2024年02月04日
    瀏覽(27)
  • 基于JAVA圖書館管理系統(tǒng)設計與實現(xiàn)

    基于JAVA圖書館管理系統(tǒng)設計與實現(xiàn)

    【后臺管理員功能】 廣告管理:設置小程序首頁輪播圖廣告和鏈接 留言列表:所有用戶留言信息列表,支持刪除 會員列表:查看所有注冊會員信息,支持刪除 資訊分類:錄入、修改、查看、刪除資訊分類 錄入資訊:錄入資訊標題、內(nèi)容等信息 管理資訊:查看已錄入資訊列

    2024年02月13日
    瀏覽(31)
  • 圖書館管理系統(tǒng)【GUI/Swing+MySQL】(Java課設)

    圖書館管理系統(tǒng)【GUI/Swing+MySQL】(Java課設)

    Swing窗口類型+Mysql數(shù)據(jù)庫存儲數(shù)據(jù) 適合作為Java課設?。。?jdk1.8+Mysql8.0+Idea或eclipse+jdbc ?本系統(tǒng)源碼地址:https://download.csdn.net/download/qq_50954361/87682509 更多Java課設系統(tǒng):更多Java課設系統(tǒng) 更多Java課設系統(tǒng)運行效果展示:更多Java課設系統(tǒng)運行效果展示? 部署教程地址:Java課設部

    2023年04月19日
    瀏覽(32)
  • Python+Django+MySQL的圖書館管理系統(tǒng)【附源碼,運行簡單】

    Python+Django+MySQL的圖書館管理系統(tǒng)【附源碼,運行簡單】

    自己做的項目,禁止轉載,基于Python+Django+MySQL的圖書館管理系統(tǒng),帶用戶登錄、注冊,基本的出版社、作者、圖書信息的增刪改查功能,還有分頁功能,用Pycharm導入,安裝依賴包,配置好數(shù)據(jù)庫就可以正常運行了,里面的代碼都含有注釋,結構簡單,清晰易懂,看一下就會

    2024年01月17日
    瀏覽(90)
  • [N-117]基于微信小程序圖書館管理系統(tǒng)

    [N-117]基于微信小程序圖書館管理系統(tǒng)

    開發(fā)工具:IDEA、微信小程序 服務器:Tomcat9.0, jdk1.8 項目構建:maven 數(shù)據(jù)庫:mysql5.7 前端技術:vue、uniapp 服務端技術:springboot+mybatis-plus 本系統(tǒng)分微信小程序和管理后臺兩部分,項目采用前后端分離 系統(tǒng)主要分為兩個角色:管理員和普通用戶。 1.普通用戶(小程序):登錄、

    2024年01月15日
    瀏覽(33)
  • java畢業(yè)設計——基于java+Java Swing+sqlserver的圖書館書庫管理系統(tǒng)設計與實現(xiàn)(畢業(yè)論文+程序源碼)——圖書館書庫管理系統(tǒng)

    java畢業(yè)設計——基于java+Java Swing+sqlserver的圖書館書庫管理系統(tǒng)設計與實現(xiàn)(畢業(yè)論文+程序源碼)——圖書館書庫管理系統(tǒng)

    大家好,今天給大家介紹基于java+Java Swing+sqlserver的圖書館書庫管理系統(tǒng)設計與實現(xiàn),文章末尾附有本畢業(yè)設計的論文和源碼下載地址哦。需要下載開題報告PPT模板及論文答辯PPT模板等的小伙伴,可以進入我的博客主頁查看左側最下面欄目中的自助下載方法哦 文章目錄: 畢業(yè)

    2024年02月03日
    瀏覽(35)
  • 基于微信小程序的圖書館管理系統(tǒng)設計與實現(xiàn)

    ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ?摘要 在當今社會,互聯(lián)網(wǎng)已經(jīng)開始成為時代的主流,隨著信息技術的發(fā)展,人們開始越來越依賴網(wǎng)絡。互聯(lián)網(wǎng)也逐漸成為我們生活中必不可少的一部分,它的出現(xiàn)也重新定義了人們獲取信息資源的

    2024年02月12日
    瀏覽(28)
  • 33基于Java簡單實現(xiàn)圖書館借書管理系統(tǒng)設計與實現(xiàn)

    33基于Java簡單實現(xiàn)圖書館借書管理系統(tǒng)設計與實現(xiàn)

    本章節(jié)給大家介紹一個基于Java簡單實現(xiàn)圖書館借書管理系統(tǒng)的設計與實現(xiàn) 項目總體分為倆種角色,分別是管理員和閱讀者,管理員可以登錄系統(tǒng)中,進行圖書管理,上架下架圖書,對用戶進行管理、對讀者進行管理、查看借閱記錄管理等,讀者角色可以登錄系統(tǒng)查詢圖書信息

    2024年02月03日
    瀏覽(26)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領取紅包,優(yōu)惠每天領

二維碼1

領取紅包

二維碼2

領紅包