基于javaweb+mysql的jsp+servlet图书图书馆管理系统(java+jsp+layui+bootstrap+servlet+mysql)

基于javaweb+mysql的jsp+servlet图书图书馆管理系统(java+jsp+layui+bootstrap+servlet+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的JSP+Servlet图书图书馆管理系统(java+jsp+layui+bootstrap+servlet+mysql)

项目介绍

使用jsp+servlet、layui、mysql完成的图书馆系统,包含用户图书借阅、图书管理员、系统管理员界面,功能齐全。

开发工具为eclipse/IDEA,环境java8,tomcat9.0+,mysql为5.7(mysql8也行)

项目详细介绍

本图书管理系统总体上分为前台页面显示和后台管理。

前台页面(即本书图书管理系统的首页)实现了公告的显示,图书查询,留言建议三大主要功能,有读者规则查看功能,师生们可以看到图书管理人员发布的最新公告信息,并可以查询自己感兴趣的图书,查看留言提议,用户登录后还有个人资料修改、个人借阅信息查询、个人违章信息查询等功能,也可以给学校的图书管理人员留言提议。

后台的页面则集成了图书管理中所需的功能,分成图书管理人员和系统管理人员,平时管理人员的工作都是在后台中完成的。前台是为了师生显示的。相对应的后台是针对学校图书管理人员,后台的页面都加密,如果不正常登录是进入不了后台管理页面的,后台图书管理人员功能包括:借阅图书、归还图书、借书记录显示与查找、还书记录显示与查找、公告增删改查;后台系统管理员功能包括:对书籍的增删改查、对书籍分类的增删改、对借阅证的增删改查、对借阅信息的显示与查找、对借阅规则的增删改、对图书管理员的增删改、对近期借阅书籍数量的折线图显示,以及对这些表格数据进行Excel表格的输出

共包含三个大模块:用户、图书管理员、系统管理员

一、用户模块

  1. 查看公告:能看到图书管理员发布的公告信息。 2. 图书查看:分页显示,能看到图书总览,能通过图书编号、图书名称、作者、存放位置、图书描述进行模糊查询 3. 个人违章信息(登录后):个人历史违章信息与查询 4. 图书馆读者留言(登录后):对图书馆的建议,或对书籍的评价 5. 查看借阅规则:不同的规则有不同的借阅限定数量、限定时间、超期费用 6. 个人信息(登录后):对个人信息的查看与登录密码的修改 7. 个人借阅信息(登录后):对个人借阅记录的分页查看与查询

二、图书管理员模块

  1. 借还图书:帮助用户借阅图书,并判断符不符合借阅规则、返还图书时判断有没有超期,超期则输出超期费用再归还 2. 借阅报表:分页显示所有借阅记录、能进行查询和输出结果到excel公告管理:能添加编辑和删除公告 3. 还书报表:分页显示所有未还的书籍,能通过借阅证号、图书编号、借阅日期、截止日期等条件进行模糊查询 4. 个人信息修改:修改个人信息、密码等

三、系统管理员模块

  1. 书籍管理:分页,新添图书,设置图书各种信息,编辑删除,通过编号、书名、作者、描述等进行搜索,输出结果到excel,并且能查看该书籍被谁借阅过。 2. 分类管理:分页显示,增删改书籍分类,书籍分类方便查阅整理 3. 借阅证管理:分页显示所有借阅证,增删改查用户借阅证,查看该借阅证所有的借阅记录 4. 借阅规则管理:能显示、编辑、删除所有借阅规则,借阅规则将决定该图书证能借阅什么图书馆的图书,能借多少本,能借多久以及超期每天的费用。 5. 借阅信息查询:分页显示,能条件查询超期没还的,根据编号、借阅证号、书籍编号、借阅日期等进行模糊查询,输出结果到excel等,系统管理员只能查询,不能增删改借阅信息,这个操作由图书管理员操作。 6. 图书管理员管理:对图书管理员进行增删改操作,但是不能修改原来的账号 7. 图书借阅统计:通过折线图将图书馆近30天的每天借阅书籍数量直观的显示出来。

sql表

共有十张数据库表,书籍表、借书记录表、留言表、系统管理员表、借阅证表、图书管理管理员表书籍分类表、图书馆表、借阅规则表、公告表 - 书籍表 - 编号、姓名、作者、存放的图书馆、分类编号、存放位置、是否借出、书籍描述 - 借书记录表 - 编号、借阅证编号、书籍编号、借书日期、限制日期、归还日期、违规描述、处理人编号 - 留言表 - 编号、借阅证编号、留言内容、留言日期 - 系统管理员表 - 账号、密码 - 借阅证表 - 编号、密码、借阅者姓名、规则编号、状态(丢失、可用) - 图书管理员表 - 编号、姓名、账号、密码、邮箱 - 书籍分类表 - 编号、分类名、分类描述 - 图书馆表 - 编号、图书馆名、描述 - 规则表 - 编号、限制借阅数量、限制借阅天数、图书超期每天费用 - 公告表 - 编号、标题、公告内容、发布日期

环境需要

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 9.x版本,注:tomcat9.0以下会有问题; 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7版本,(mysql8也行)

技术栈

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

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven;若为maven项目,导入成功后请执行maven clean;maven install命令,配置tomcat,然后运行; 3. 将项目中src/javabean/Base.java和JDBCBean.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入localhost:8080/xxx 登录 5. 用户账号密码:1805010219 1234 图书管理员账号密码:root 1234 系统管理员账号密码:admin admin
		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();
				// 返回删除记录条数
				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());
	}

}
		PrintWriter out = resp.getWriter();
		out.print(jsonResult.toString());
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	}

}

/**
 * Servlet implementation class Borrow
 */
@WebServlet("/reader/borrow")
public class Borrow extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		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 = ""; // 无限制条件
		if (page == null) {
			page = "1";
		}
		if (limit == null) {
			limit = "10";
		}
				msg = "sql错误";
			} finally {
				try {
					Base.closeResource(connection, pstmt, resultSet);
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			out.print(Util.jsonResponse(code, msg, null));
		}
	}
}

@WebServlet("/admin/updatePassword")
public class UpdatePassword extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 接受数据
		String oldPassword = req.getParameter("oldPassword");
		String newPassword = req.getParameter("newPassword");
		String conPassword = req.getParameter("conPassword");
		HttpSession session = req.getSession();
		String username = (String) session.getAttribute("admin");
					sql = "insert into manager(name, account, password, email) values(?,?,?,?)";
					pstmt = connection.prepareStatement(sql);
					pstmt.setString(1, name);
					pstmt.setString(2, account);
					pstmt.setString(3, password);
					pstmt.setString(4, email);
					result = pstmt.executeUpdate();
				}
				// 返回数据
				if(result == 1 && count == 0) {
					code = 0;
					msg = "添加成功";
				}else if(count > 0){
					msg = "账号重复";
				}else {
					msg = "添加失败";
				}
			} catch (ClassNotFoundException e) {
				msg = "class not found";
			} catch (SQLException e) {
				msg = "sql错误";
			} finally {
				try {
					Base.closeResource(connection, pstmt, resultSet);
				} catch (SQLException e) {
					e.printStackTrace();
				}
			}
			out.print(Util.jsonResponse(code, msg, null));
		}
	}
}

				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 = "关闭资源失败";
			}

		}
		// 返回数据
		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());
	}

}


@WebServlet("/admin/managerAdd")
public class ManagerAdd extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 接收参数
		String name = req.getParameter("name");
		String account = req.getParameter("account");
		String password = req.getParameter("password");
		String email = req.getParameter("email");
		// 准备参数
		String sql = "";
		Connection  connection = null;
		PreparedStatement pstmt = null;
		ResultSet resultSet = null;
		int result = 0;
		int count = 0;
		// 返回参数
		int code = 1;
		String msg = "";
		PrintWriter out = resp.getWriter();
		JSONArray jsonArray = new JSONArray();
		JSONObject jsonObject  = new JSONObject();
		// 进行查询
		if(name==null || name.equals("") || account==null || account.equals("") || password==null || password.equals("") || email==null || email.equals("")) {
			msg = "参数不能为空";
			out.print(Util.jsonResponse(code, msg, null));
		}else {
			try {
				connection = (Connection) Base.getConnection();
				// 验证账号
				sql = "select count(*) as count from manager where account=?";
				pstmt = connection.prepareStatement(sql);
				pstmt.setString(1, account);
				resultSet = pstmt.executeQuery();
				resultSet.next();
			} catch (SQLException e) {
				msg = "关闭资源失败";
			}

		}
		// 返回数据
		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());
	}

}

@WebServlet("/manager1/borrowTable")
public class BorrowTable extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 接收参数
		String limit = req.getParameter("limit");

public class XSSFilter implements Filter {
	public String filter(String htmlStr){
		if(htmlStr == null) {
			return null;
		}
        String regEx_script = "<script[^>]*?>[\\s\\S]*?<\\/script>"; // 定义script的正则表达式 
        String regEx_style = "<style[^>]*?>[\\s\\S]*?<\\/style>"; // 定义style的正则表达式 
        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对象获取表单提交的数据,
     * (主要通过 getParameter() 和 getParameterValues()
     * 方法获取),再此创建内部类Request,重写getParameter()
     * 和 getParameterValues(),并在重写的两个方法中实现过滤 
     */

    class Request extends HttpServletRequestWrapper{// HttpServletRequest                                                                      //Wrapper是servletRequest的实现类

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

        @Override
        public String getParameter(String name) {
            // 返回过滤后的参数值
            return filter(super.getRequest().getParameter(name));
        }

				code = "0";
				msg = "添加成功";
			}else {
				code = "1";
				msg = "执行失败";
			}
		}
		json.put("code", code);
		json.put("msg", msg);
		json.put("data", jsonData.toString());
		PrintWriter out = resp.getWriter();
		out.print(json.toString());
	}

}

@WebServlet("/admin/managerAdd")
public class ManagerAdd extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 接收参数
		String name = req.getParameter("name");
		String account = req.getParameter("account");
		String sql = "";
		Connection  connection = null;
		PreparedStatement pstmt = null;
		ResultSet resultSet = null;
		int result = 0;
		int count = 0;
		// 返回参数
		int code = 1;
		String msg = "";
		PrintWriter out = resp.getWriter();
		JSONArray jsonArray = new JSONArray();
		JSONObject jsonObject  = new JSONObject();
		// 进行查询
		if(name==null || name.equals("") || account==null || account.equals("") || password==null || password.equals("") || email==null || email.equals("")) {
			msg = "参数不能为空";
			out.print(Util.jsonResponse(code, msg, null));
		}else {
			try {
				connection = (Connection) Base.getConnection();
				// 验证账号
				sql = "select count(*) as count from manager where account=?";
				pstmt = connection.prepareStatement(sql);
				pstmt.setString(1, account);
				resultSet = pstmt.executeQuery();
				resultSet.next();
				count = resultSet.getInt("count");
				// 添加管理员
				if(count == 0) {
					sql = "insert into manager(name, account, password, email) values(?,?,?,?)";
					pstmt = connection.prepareStatement(sql);
					pstmt.setString(1, name);
					pstmt.setString(2, account);
					pstmt.setString(3, password);
					pstmt.setString(4, email);
					result = pstmt.executeUpdate();
				}
				// 返回数据
				if(result == 1 && count == 0) {
					code = 0;
					msg = "添加成功";
				}else if(count > 0){
					msg = "账号重复";
				}else {
					msg = "添加失败";
				}
			} catch (ClassNotFoundException e) {
				msg = "class not found";
			} catch (SQLException e) {
				msg = "sql错误";
			} finally {
			limit = "10";
		}
		// 准备查询
		Connection connection = null;
		PreparedStatement pstmt = null;
		PreparedStatement countPstmt = null;
		ResultSet resultSet = null;
		ResultSet countSet = null;
		String sql = "";
		String countSql = "";
		// 准备返回参数
		int code = 1;
		String msg = "无数据";
		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("")) {
				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"));

				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 = "查询成功";
			}

		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;
		// 参数不能为空
		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();
				String findIdSql = "select id from borrow_card where password=? and reader=? and rule_id=? and status=? limit 1";
				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 = "发生异常";
			} catch (SQLException e) {
				msg = "sql错误";
				System.out.println("sql失败");
			} 
			try {
				Base.closeResource(connection, pstmt, null);
				Base.closeResource(connection1, pstmt1, dataSet);
			} catch (SQLException e) {
				msg = "关闭资源失败";
				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());
	}

}

/**
 * Servlet implementation class BookList
 */
@WebServlet("/admin/bookList")
public class BookList extends HttpServlet {
       
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		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();
	}
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		doPost(req, resp);
	}
	 *      response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response)
			throws ServletException, IOException {

	}

}

/**
 * Servlet implementation class Borrow
 */
@WebServlet("/reader/borrow")
public class Borrow extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		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");

/**
 * Servlet implementation class CardList
 */
@WebServlet("/admin/cardList")
public class CardList extends HttpServlet {
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		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";
		}
		Connection connection = null;
		PreparedStatement pstmt = null;
		ResultSet resultSet = null;
		int code = 1;
		String msg = "error";
			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 = "关闭资源失败";
			}

		}
		// 返回数据
		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());
	}

}


@WebServlet("/admin/managerEdit")
public class ManagerEdit extends HttpServlet {
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		resp.setContentType("application/json; charset=utf8");
		// 接收参数
		String id = req.getParameter("id");
		String name = req.getParameter("name");
		String password = req.getParameter("password");
		String email = req.getParameter("email");
		// 准备参数
		String sql = "";
		Connection  connection = null;
		PreparedStatement pstmt = null;
		ResultSet resultSet = null;
		int result = 0;
		// 返回参数
		int code = 1;
		String msg = "";
		PrintWriter out = resp.getWriter();
		JSONArray jsonArray = new JSONArray();
		JSONObject jsonObject  = new JSONObject();
		// 进行查询
		if(name==null || name.equals("")|| password==null || password.equals("") || email==null || email.equals("")) {
			msg = "参数不能为空";
			out.print(Util.jsonResponse(code, msg, null));
		}else {
			try {
				connection = (Connection) Base.getConnection();
				// 添加管理员
				sql = "update manager set name=?, password=?, email=? where id=?";
				pstmt = connection.prepareStatement(sql);
				pstmt.setString(1, name);
				pstmt.setString(2, password);
				pstmt.setString(3, email);
				pstmt.setString(4, id);
				result = pstmt.executeUpdate();
				
				// 返回数据
				if(result == 1 ){
					code = 0;
					msg = "修改成功";
				}else {
					msg = "修改失败";

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
图书管理系统总体上分为前台页面显示和后台管理。 前台页面(即本书图书管理系统的首页)实现了公告的显示,图书查询,留言建议三大主要功能,有读者规则查看功能,师生们可以看到图书管理人员发布的最新公告信息,并可以查询自己感兴趣的图书,查看留言提议,用户登录后还有个人资料修改、个人借阅信息查询、个人违章信息查询等功能,也可以给学校的图书管理人员留言提议。 后台的页面则集成了图书管理中所需的功能,分成图书管理人员和系统管理人员,平时管理人员的工作都是在后台中完成的。前台是为了师生显示的。相对应的后台是针对学校图书管理人员,后台的页面都加密,如果不正常登录是进入不了后台管理页面的,后台图书管理人员功能包括:借阅图书、归还图书、借书记录显示与查找、还书记录显示与查找、公告增删改查;后台系统管理员功能包括:对书籍的增删改查、对书籍分类的增删改、对借阅证的增删改查、对借阅信息的显示与查找、对借阅规则的增删改、对图书管理员的增删改、对近期借阅书籍数量的折线图显示,以及对这些表格数据进行Excel表格的输出 共包含三个大模块:用户、图书管理员、系统管理员 一、用户模块 查看公告:能看到图书管理员发布的公告信息。 图书查看:分页显示,能看到图书总览,能通过图书编号、图书名称、作者、存放位置、图书描述进行模糊查询 个人违章信息(登录后):个人历史违章信息与查询 图书馆读者留言(登录后):对图书馆的建议,或对书籍的评价 查看借阅规则:不同的规则有不同的借阅限定数量、限定时间、超期费用 个人信息(登录后):对个人信息的查看与登录密码的修改 个人借阅信息(登录后):对个人借阅记录的分页查看与查询 二、图书管理员模块 借还图书:帮助用户借阅图书,并判断符不符合借阅规则、返还图书时判断有没有超期,超期则输出超期费用再归还 借阅报表:分页显示所有借阅记录、能进行查询和输出结果到excel公告管理:能添加编辑和删除公告 还书报表:分页显示所有未还的书籍,能通过借阅证号、图书编号、借阅日期、截止日期等条件进行模糊查询 个人信息修改:修改个人信息、密码等 三、系统管理员模块 书籍管理:分页,新添图书,设置图书各种信息,编辑删除,通过编号、书名、作者、描述等进行搜索,输出结果到excel,并且能查看该书籍被谁借阅过。 分类管理:分页显示,增删改书籍分类,书籍分类方便查阅整理 借阅证管理:分页显示所有借阅证,增删改查用户借阅证,查看该借阅证所有的借阅记录 借阅规则管理:能显示、编辑、删除所有借阅规则,借阅规则将决定该图书证能借阅什么图书馆的图书,能借多少本,能借多久以及超期每天的费用。 借阅信息查询:分页显示,能条件查询超期没还的,根据编号、借阅证号、书籍编号、借阅日期等进行模糊查询,输出结果到excel等,系统管理员只能查询,不能增删改借阅信息,这个操作由图书管理员操作。 图书管理员管理:对图书管理员进行增删改操作,但是不能修改原来的账号 图书借阅统计:通过折线图将图书馆近30天的每天借阅书籍数量直观的显示出来。 sql表 共有十张数据库表,书籍表、借书记录表、留言表、系统管理员表、借阅证表、图书管理管理员表书籍分类表、图书馆表、借阅规则表、公告表 书籍表 编号、姓名、作者、存放的图书馆、分类编号、存放位置、是否借出、书籍描述 借书记录表 编号、借阅证编号、书籍编号、借书日期、限制日期、归还日期、违规描述、处理人编号 留言表 编号、借阅证编号、留言内容、留言日期 系统管理员表 账号、密码 借阅证表 编号、密码、借阅者姓名、规则编号、状态(丢失、可用) 图书管理员表 编号、姓名、账号、密码、邮箱 书籍分类表 编号、分类名、分类描述 图书馆表 编号、图书馆名、描述 规则表 编号、限制借阅数量、限制借阅天数、图书超期每天费用 公告表 编号、标题、公告内容、发布日期

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值