——————————DescriptionStart——————————
运行环境 Java≥8、MySQL≥5.7、Tomcat≥8
开发工具 eclipse/idea/myeclipse/sts等均可配置运行
适用 课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明
基于javaweb的JSP+Servlet图书借阅管理系统(java+jsp+bootstrap+jquery+servlet+mysql)
项目介绍
本项目分为读者、管理员两种角色,登录验证码。 管理员主要功能包括: 图书管理:1)根据图书名称、作者、分类查询图书基本信息 2)添加、修改或删除图书信息
读者管理:1)根据账号、姓名、ID查询读者基本信息 2)添加、修改或删除读者信息
图书分类管理:1)查看图书分类信息,显示分类ID 2)添加、修改或删除图书分类
图书借阅信息:1)展示所有正在借阅的图书信息与读者信息 2)可以实现还书与延期功能
图书归还信息:1)展示所有已归还的图书的信息 2)记录图书出馆时间与归馆时间
管理员管理(需登录):1)仅最高管理员可以访问本页面 2)添加、修改或删除管理员信息
热门推荐:1)展示每一本书的借阅量,包括图书基本信息 2)可以查询书籍借阅量 最佳读者:展示每一位已知读者的借阅量,以及读者的基本信息
读者登录主要功能包括: 图书查询、借阅信息、借阅历史、热门推荐、最佳读者、问题反馈;
环境需要
1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.数据库:MySql 5.7版本; 6.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目
技术栈
后端:Servlet 2. 前端:JSP+bootstrap+jQuery
使用说明
使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,Eclipse/MyEclipse导入时,若为maven项目请选择maven; 若为maven项目,导入成功后请执行maven clean;maven install命令,然后运行; 3. 将项目中util/DBUtil.java配置文件中的数据库配置改为自己的配置; 4. 运行项目,输入http://localhost:8080/books/login.jsp 登录 注:tomcat中配置项目路径必须为/books 管理员用户名密码:101/101.123456 读者用户名密码:1816270150/wyz123456
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 @WebServlet("/LoginServlet") public class LoginServlet extends HttpServlet { private static final long serialVersionUID = 1L ; public LoginServlet () { super (); } protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8" ); response.setContentType("text/html;charset=UTF-8" ); String username = request.getParameter("username" ); String password = request.getParameter("password" ); String text = request.getParameter("code" ); String code = (String) request.getSession().getAttribute("code" ); AdminDao userdao = new AdminDao();
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 @WebServlet("/brtimesServlet") public class brtimesServlet extends HttpServlet { private static final long serialVersionUID = 1L ; public brtimesServlet () { super (); } protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8" ); response.setContentType("text/html;charset=UTF-8" ); int tip = Integer.parseInt(request.getParameter("tip" )); String name = request.getParameter("name" ); AdminDao admindao = new AdminDao(); ArrayList<AdminBean> data = admindao.getLikeList(name); request.setAttribute("data" , data); String url = "" ; if (tip == 1 ) { url = response.encodeURL("admin_brtimes.jsp" ); } else { url = response.encodeURL("brtimes.jsp" ); } request.getRequestDispatcher(url).forward(request, response); } }
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 @WebServlet("/selectServlet") public class selectServlet extends HttpServlet { private static final long serialVersionUID = 1L ; public selectServlet () { super (); } protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8" ); response.setContentType("text/html;charset=UTF-8" ); int tip = Integer.parseInt(request.getParameter("tip" )); String name = request.getParameter("name" ); BookDao bookdao = new BookDao(); ArrayList<BookBean> data = bookdao.getLikeList(name); request.setAttribute("data" , data); String url = "" ; if (tip == 1 ) { url = response.encodeURL("admin_book.jsp" );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 public AdminServlet () { super (); } protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { PrintWriter out = response.getWriter(); request.setCharacterEncoding("UTF-8" ); response.setContentType("text/html;charset=UTF-8" ); int tip = Integer.parseInt(request.getParameter("tip" )); String url = request.getParameter("url" ); HttpSession session = request.getSession(); AdminBean adminbean = new AdminBean(); String aid = (String) session.getAttribute("aid" ); AdminDao admindao = new AdminDao(); adminbean = admindao.get_AidInfo2(aid); if (tip == 1 ) { String password = request.getParameter("password" );
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 } protected void doGet (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("UTF-8" ); response.setContentType("text/html;charset=UTF-8" ); String card = request.getParameter("card" ); String name = request.getParameter("name" ); String type = request.getParameter("type" ); String autho = request.getParameter("autho" ); String press = request.getParameter("press" ); int num = Integer.parseInt(request.getParameter("num" )); int bid = Integer.parseInt(request.getParameter("updatebid" )); BookDao bookdao = new BookDao(); bookdao.updateBook(bid, card, name, type, autho, press, num); response.sendRedirect("/books/admin_book.jsp" ); } } package com.rain.servlet;
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse * response) */ protected void doPost (HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8" ); BufferedImage bfi = new BufferedImage(80 , 25 , BufferedImage.TYPE_INT_RGB); Graphics g = bfi.getGraphics(); g.fillRect(0 , 0 , 80 , 25 ); char [] ch = "0123456789" .toCharArray(); Random r = new Random(); int index; StringBuffer sb = new StringBuffer(); for (int i = 0 ; i < 4 ; i++) { index = r.nextInt(ch.length); g.setColor(new Color(r.nextInt(255 ), r.nextInt(255 ), r.nextInt(255 ))); Font font = new Font("宋体" , 30 , 20 ); g.setFont(font); g.drawString(ch[index] + "" , (i * 20 ) + 2 , 23 ); sb.append(ch[index]); } for (int i = 0 ; i < 6 ; i++) { int xstart = (int ) (Math.random() * 80 ); int ystart = (int ) (Math.random() * 25 ); int xend = (int ) (Math.random() * 80 ); int yend = (int ) (Math.random() * 25 ); g.setColor(interLine(1 , 255 )); g.drawLine(xstart, ystart, xend, yend); } HttpSession session = request.getSession(); session.setAttribute("code" , sb.toString()); ImageIO.write(bfi, "JPG" , response.getOutputStream()); } private static Color interLine (int Low, int High) { if (Low > 255 ) Low = 255 ; if (High > 255 ) High = 255 ; if (Low < 0 ) Low = 0 ; if (High < 0 ) High = 0 ; int interval = High - Low; int r = Low + (int ) (Math.random() * interval); int g = Low + (int ) (Math.random() * interval); int b = Low + (int ) (Math.random() * interval);
——————————PayStart——————————
项目链接: https://javayms.github.io?id=151122522008200oc https://javayms.pages.dev?id=151122522008200oc