└── README.md /README.md: -------------------------------------------------------------------------------- 1 | 2 | 3 | **计算机类毕设源码大全:[十几套计算机专业毕业设计文档及源码分享](https://mp.weixin.qq.com/mp/homepage?__biz=MzkyMDAxNTQ4NQ==&hid=5&sn=097a81acff1e1971604ea1b571c13b9e&scene=18)** 4 | 5 | **系统演示链接:[点击这里查看演示](http://books.cyouagain.cn)** 6 | 7 | **获取源码:微信搜索公众号【IT学长】回复“基于web的图书管理系统”** 8 | 9 | **详细开发文档:[《基于Web的图书管理系统设计与实现(附源码下载地址)》](https://mp.weixin.qq.com/s/zZ40HrMcNoUx87aH8dGfhw)** 10 | 11 | **运行教程:[《基于Web的图书管理系统运行教程》](https://mp.weixin.qq.com/s/tMrcyR2cpHfZ4NjGdBUIrA)** 12 | 13 | **演示截图:[《基于Web的图书管理系统演示截图》](https://blog.csdn.net/m0_73470247/article/details/126644988)** 14 | 15 | @[toc] 16 | 17 | ## 01 系统简述 18 | 图书管理系统就是利用计算机,结合互联网对图书进行结构化、自动化管理的一种软件,来提高对图书的管理效率。本系统采用Java+Servlet+Jsp 的方式实现基于web的图书管理系统。 19 | 20 | ## 02 开发工具及相关技术 21 | #### 2.1 Java技术 22 | Java 是由 Sun Microsystems 在 1995 年首先发布的编程语言和计算平台。有许多应用程序和 Web 站点只有在安装 Java 后才能正常工作,而且这样的应用程序和 Web 站点日益增多。Java 快速、安全、可靠。从笔记本电脑到数据中心,从游戏控制台到科学超级计算机,从手机到互联网,Java 无处不在。 23 | 24 | #### 2.2 HTML、css、javascript技术 25 | HTML的英文全称是 Hypertext Marked Language,即超文本标记语言。HTML是由Web的发明者 Tim Berners-Lee和同事 Daniel W. Connolly于1990年创立的一种标记语言,它是标准通用化标记语言SGML的应用。用HTML编写的超文本文档称为HTML文档,它能独立于各种操作系统平台(如UNIX, Windows等)。使用HTML语言,将所需要表达的信息按某种规则写成HTML文件,通过专用的浏览器来识别,并将这些HTML文件“翻译”成可以识别的信息,即现在所见到的网页。 26 | 27 | 层叠样式表(英文全称:Cascading Style Sheets)是一种用来表现HTML(标准通用标记语言的一个应用)或XML(标准通用标记语言的一个子集)等文件样式的计算机语言。CSS不仅可以静态地修饰网页,还可以配合各种脚本语言动态地对网页各元素进行格式化。CSS 能够对网页中元素位置的排版进行像素级精确控制,支持几乎所有的字体字号样式,拥有对网页对象和模型样式编辑的能力。 28 | 29 | JavaScript(简称“JS”) 是一种具有函数优先的轻量级,解释型或即时编译型的编程语言。虽然它是作为开发Web页面的脚本语言而出名的,但是它也被用到了很多非浏览器环境中,JavaScript 基于原型编程、多范式的动态脚本语言,并且支持面向对象、命令式和声明式(如函数式编程)风格。JavaScript在1995年由Netscape公司的Brendan Eich,在网景导航者浏览器上首次设计实现而成。因为Netscape与Sun合作,Netscape管理层希望它外观看起来像Java,因此取名为JavaScript。但实际上它的语法风格与Self及Scheme较为接近。JavaScript的标准是ECMAScript 。截至 2012 年,所有浏览器都完整的支持ECMAScript 5.1,旧版本的浏览器至少支持ECMAScript 3 标准。2015年6月17日,ECMA国际组织发布了ECMAScript 的第六版,该版本正式名称为 ECMAScript 2015,但通常被称为ECMAScript 6 或者ES6。 30 | 31 | #### 2.3 Servlet技术 32 | Servlet(Server Applet)是Java Servlet的简称,称为小服务程序或服务连接器,用Java编写的服务器端程序,具有独立于平台和协议的特性,主要功能在于交互式地浏览和生成数据,生成动态Web内容。 33 | 34 | 狭义的Servlet是指Java语言实现的一个接口,广义的Servlet是指任何实现了这个Servlet接口的类,一般情况下,人们将Servlet理解为后者。Servlet运行于支持Java的应用服务器中。从原理上讲,Servlet可以响应任何类型的请求,但绝大多数情况下Servlet只用来扩展基于HTTP协议的Web服务器。 35 | #### 2.4 Eclipse开发工具 36 | Eclipse 是一个开放源代码的、基于Java的可扩展开发平台。就其本身而言,它只是一个框架和一组服务,用于通过插件组件构建开发环境。幸运的是,Eclipse 附带了一个标准的插件集,包括Java开发工具(Java Development Kit,JDK)。 37 | 38 | #### 2.5 MySql数据库 39 | MySql是最流行的关系型数据库管理系统,在WEB应用方面MySQL是最好的RDBMS(Relational Database Management System:关系数据库管理系统)应用软件之一。MySql数据库有以下特点: 40 | 41 | 1. Mysql是开源的,所以你不需要支付额外的费用。 42 | 3. Mysql支持大型的数据库。可以处理拥有上千万条记录的大型数据库。 43 | 4. MySQL使用标准的SQL数据语言形式。 44 | 5. Mysql可以允许于多个系统上,并且支持多种语言。这些编程语言包括C、C++、Python、Java、Perl、PHP、Eiffel、Ruby和Tcl等。 45 | 6. Mysql对PHP有很好的支持,PHP是目前最流行的Web开发语言。 46 | 7. MySQL支持大型数据库,支持5000万条记录的数据仓库,32位系统表文件最大可支持4GB,64位系统支持最大的表文件为8TB。 47 | 8. Mysql是可以定制的,采用了GPL协议,你可以修改源码来开发自己的Mysql系统。 48 | 49 | ## 03 系统功能描述 50 | 系统的用户主要有两大类:一是图书管理系统的管理员,二是普通用户。根据用户类型的不同,将系统划分为普通用户端和管理员端,它们具有的主要功能如下: 51 | 52 | **用户端** 53 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711142212377.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwNjI1Nzc4,size_16,color_FFFFFF,t_70) 54 | 55 | 图书查询:根据图书编号、图书名称查询图书信息,可查询图书的编号、名称、分类、作者、价格、在馆数量等。 56 | 57 | 借阅信息:可查询图书的基本信息、借阅日期、截止还书日期、超期天数等。 58 | 59 | 借阅历史:查询自己以往的借阅历史,包括哪些图书等具体信息。 60 | 61 | 我的:查看个人资料,修改账户密码,退出系统。 62 | 63 | **管理员端** 64 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711142331762.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwNjI1Nzc4,size_16,color_FFFFFF,t_70) 65 | 图书管理:根据图书编号、图书名称查询图书基本信息,添加、修改、删除图书。 66 | 67 | 图书分类管理:根据分类名称查询图书分类信息,添加、修改、删除图书分类。 68 | 69 | 图书借阅:展示所有正在借阅图书的信息。 70 | 71 | 图书归还:展示所有已归还图书的信息。 72 | 73 | 公告管理:向用户发布公告。 74 | 75 | 读者管理:根据账号、姓名查询读者基本信息,添加、修改、删除读者信息。 76 | 77 | 我的:查看个人资料,修改账户密码,退出系统。 78 | 79 | ## 04 工程结构及其说明 80 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711142439453.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwNjI1Nzc4,size_16,color_FFFFFF,t_70) 81 | 项目名称:manage_books 82 | Package包说明: 83 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711142614767.png) 84 | 85 | ## 05 主要功能详细设计与实现 86 | #### 5.1 用户端--图书查询模块 87 | 用户访问图书查询模块时显示当前可以借阅图书,有按图书名称查询图书信息的功能,可以进行借书操作。 88 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711142820895.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwNjI1Nzc4,size_16,color_FFFFFF,t_70) 89 | 其中查询功能的Servlet代码如下: 90 | 91 | ```java 92 | package com.cya.controller; 93 | import java.io.IOException; 94 | import java.util.ArrayList; 95 | import javax.servlet.ServletException; 96 | import javax.servlet.annotation.WebServlet; 97 | import javax.servlet.http.HttpServlet; 98 | import javax.servlet.http.HttpServletRequest; 99 | import javax.servlet.http.HttpServletResponse; 100 | import com.cya.dao.BookDao; 101 | import com.cya.pojo.Book; 102 | /** 103 | * Servlet implementation class selectServlet 104 | */ 105 | @WebServlet("/selectServlet") 106 | public class selectServlet extends HttpServlet { 107 | private static final long serialVersionUID = 1L; 108 | 109 | /** 110 | * @see HttpServlet#HttpServlet() 111 | */ 112 | public selectServlet() { 113 | super(); 114 | // TODO Auto-generated constructor stub 115 | } 116 | 117 | /** 118 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 119 | */ 120 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 121 | // TODO Auto-generated method stub 122 | //response.getWriter().append("Served at: ").append(request.getContextPath()); 123 | 124 | } 125 | 126 | /** 127 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) 128 | */ 129 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 130 | // TODO Auto-generated method stub 131 | //doGet(request, response); 132 | request.setCharacterEncoding("UTF-8"); 133 | response.setContentType("text/html;charset=UTF-8"); 134 | //因为在管理员界面和读者界面都有查找功能,为了将查找的结果返回正确的页面,设置了tip,tip=1表示管理员界面 135 | int tip = Integer.parseInt(request.getParameter("tip")); 136 | String name = request.getParameter("name"); 137 | BookDao bookdao = new BookDao(); 138 | ArrayList data = bookdao.getLikeList(name); 139 | //将获取的结果存入请求中 140 | request.setAttribute("data", data); 141 | String url = ""; 142 | //转发不同的界面 143 | if (tip == 1) { 144 | url = response.encodeURL("/books/admin/admin_books.jsp"); 145 | } else { 146 | url = response.encodeURL("/books/user/select.jsp"); 147 | } 148 | //将请求转发 149 | request.getRequestDispatcher(url).forward(request, response); 150 | } 151 | 152 | } 153 | ``` 154 | 155 | #### 5.2 用户端--借阅信息模块 156 | 当普通用户借阅完图书,会在该模块自动生成借阅信息,如借阅日期,归还日期,也可在该模块进行还书,如下图所示。 157 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711143029669.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwNjI1Nzc4,size_16,color_FFFFFF,t_70) 158 | 其中,还书功能的Servlet代码如下: 159 | 160 | ```java 161 | package com.cya.controller; 162 | import java.io.IOException; 163 | import java.io.PrintWriter; 164 | import javax.servlet.ServletException; 165 | import javax.servlet.annotation.WebServlet; 166 | import javax.servlet.http.HttpServlet; 167 | import javax.servlet.http.HttpServletRequest; 168 | import javax.servlet.http.HttpServletResponse; 169 | import javax.servlet.http.HttpSession; 170 | import com.cya.pojo.Admin; 171 | import com.cya.dao.AdminDao; 172 | import com.cya.dao.BookDao; 173 | /** 174 | * Servlet implementation class borrowServlet 175 | */ 176 | @WebServlet("/borrowServlet") 177 | public class borrowServlet extends HttpServlet { 178 | private static final long serialVersionUID = 1L; 179 | 180 | /** 181 | * @see HttpServlet#HttpServlet() 182 | */ 183 | public borrowServlet() { 184 | super(); 185 | // TODO Auto-generated constructor stub 186 | } 187 | 188 | /** 189 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 190 | */ 191 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 192 | // TODO Auto-generated method stub 193 | //response.getWriter().append("Served at: ").append(request.getContextPath()); 194 | //设置编码类型 195 | request.setCharacterEncoding("UTF-8"); 196 | response.setContentType("text/html;charset=UTF-8"); 197 | BookDao bookdao = new BookDao(); 198 | //为了区分借书和还书的功能,设置tip,tip为1,表示借书 199 | int tip = Integer.parseInt(request.getParameter("tip")); 200 | if (tip == 1) { 201 | //获取图书id 202 | int bid = Integer.parseInt(request.getParameter("bid")); 203 | HttpSession session = request.getSession(); 204 | Admin admin = new Admin(); 205 | String status=request.getParameter("status"); 206 | String id=""; 207 | if(status.equals("user")) { 208 | //获取到存入session的读者id 209 | id = (String) session.getAttribute("uid"); 210 | } 211 | else { 212 | //获取到存入session的aid读者id 213 | id = (String) session.getAttribute("aid"); 214 | } 215 | 216 | AdminDao admindao = new AdminDao(); 217 | //通过aid获取到读者的信息 218 | admin = admindao.get_AidInfo2(id); 219 | //将借阅记录存入数据表 220 | bookdao.borrowBook(bid, admin); 221 | response.sendRedirect("/manage_books/books/user/select.jsp"); 222 | } else { 223 | //还书功能,获取借阅记录的hid 224 | int hid = Integer.parseInt(request.getParameter("hid")); 225 | /** 226 | * 还书在管理员和读者界面都有,为了区分,设置了show字段,show为1表示读者界面 227 | */ 228 | int show = Integer.parseInt(request.getParameter("show")); 229 | //调用还书函数,改变status字段 230 | bookdao.borrowBook2(hid); 231 | if (show == 1) { 232 | response.sendRedirect("/manage_books/books/user/borrow.jsp"); 233 | } else { 234 | response.sendRedirect("/manage_books/books/admin/admin_borrows.jsp"); 235 | } 236 | 237 | } 238 | 239 | } 240 | 241 | /** 242 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) 243 | */ 244 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 245 | // TODO Auto-generated method stub 246 | doGet(request, response); 247 | } 248 | 249 | } 250 | ``` 251 | #### 5.3 管理员端--图书管理模块 252 | 管理员可以通过根据图书号 、图书名称,作者名称,出版社等查询图书信息。 253 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711143221127.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwNjI1Nzc4,size_16,color_FFFFFF,t_70) 254 | 255 | 管理员登录系统以后,可以进行图书添加操作,这是管理员主要的输入信息部分,填写好各项信息后,单击保存按钮,系统将对这些信息进行处理。界面见下图所示: 256 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711143310535.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwNjI1Nzc4,size_16,color_FFFFFF,t_70) 257 | 258 | 除此以外,管理员对已经添加好的图书信息有修改权限。 259 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711143409474.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L3FxXzQwNjI1Nzc4,size_16,color_FFFFFF,t_70) 260 | 其中,添加图书功能的代码如下: 261 | 262 | ```java 263 | package com.cya.controller; 264 | import java.io.IOException; 265 | import javax.servlet.ServletException; 266 | import javax.servlet.annotation.WebServlet; 267 | import javax.servlet.http.HttpServlet; 268 | import javax.servlet.http.HttpServletRequest; 269 | import javax.servlet.http.HttpServletResponse; 270 | import com.cya.dao.BookDao; 271 | /** 272 | * Servlet implementation class AddBookServlet 273 | */ 274 | @WebServlet("/AddBookServlet") 275 | public class AddBookServlet extends HttpServlet { 276 | private static final long serialVersionUID = 1L; 277 | 278 | /** 279 | * @see HttpServlet#HttpServlet() 280 | */ 281 | public AddBookServlet() { 282 | super(); 283 | // TODO Auto-generated constructor stub 284 | } 285 | 286 | /** 287 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 288 | */ 289 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 290 | // TODO Auto-generated method stub 291 | // response.getWriter().append("Served at: ").append(request.getContextPath()); 292 | } 293 | 294 | /** 295 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) 296 | */ 297 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 298 | // TODO Auto-generated method stub 299 | // doGet(request, response); 300 | //设置编码类型 301 | request.setCharacterEncoding("UTF-8"); 302 | response.setContentType("text/html;charset=UTF-8"); 303 | //获取要添加图书的信息 304 | String card = request.getParameter("card"); 305 | String name = request.getParameter("name"); 306 | String type = request.getParameter("type"); 307 | String autho = request.getParameter("autho"); 308 | String press = request.getParameter("press"); 309 | int num = Integer.parseInt(request.getParameter("num")); 310 | BookDao bookdao = new BookDao(); 311 | //调用函数,存入图书 312 | bookdao.addBook(card, name, type, autho, press, num); 313 | response.sendRedirect("/manage_books/books/admin/admin_books.jsp"); 314 | } 315 | 316 | } 317 | ``` 318 | 319 | #### 5.4 管理员端--图书分类模块 320 | 管理员在该界面可以增加、删除、修改图书分类信息,操作效果如图。 321 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711143555646.png) 322 | ![在这里插入图片描述](https://img-blog.csdnimg.cn/20200711143617913.png) 323 | 修改图书分类功能的代码如下: 324 | 325 | ```java 326 | package com.cya.controller; 327 | import java.io.IOException; 328 | import javax.servlet.ServletException; 329 | import javax.servlet.annotation.WebServlet; 330 | import javax.servlet.http.HttpServlet; 331 | import javax.servlet.http.HttpServletRequest; 332 | import javax.servlet.http.HttpServletResponse; 333 | import com.cya.dao.BookDao; 334 | import com.cya.dao.TypeDao; 335 | /** 336 | * Servlet implementation class updateBookTypeServlet 337 | */ 338 | @WebServlet("/updateBookTypeServlet") 339 | public class updateBookTypeServlet extends HttpServlet { 340 | private static final long serialVersionUID = 1L; 341 | 342 | /** 343 | * @see HttpServlet#HttpServlet() 344 | */ 345 | public updateBookTypeServlet() { 346 | super(); 347 | // TODO Auto-generated constructor stub 348 | } 349 | 350 | /** 351 | * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) 352 | */ 353 | protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 354 | // TODO Auto-generated method stub 355 | // response.getWriter().append("Served at: ").append(request.getContextPath()); 356 | } 357 | 358 | /** 359 | * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) 360 | */ 361 | protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { 362 | // TODO Auto-generated method stub 363 | // doGet(request, response); 364 | //修改图书类型信息 365 | request.setCharacterEncoding("UTF-8"); 366 | response.setContentType("text/html;charset=UTF-8"); 367 | String name = request.getParameter("name"); 368 | int tid = Integer.parseInt(request.getParameter("tid")); 369 | TypeDao typedao = new TypeDao(); 370 | typedao.updateTypeBook(tid, name); 371 | response.sendRedirect("/manage_books/books/admin/admin_booksType.jsp"); 372 | } 373 | 374 | } 375 | ``` 376 | 377 | ## 06 源码下载 378 | 379 | 本期文章就分享到这里,创作不易欢迎点赞分享!原创文章,转载请注明出处。如需**本系统完整源码请在微信搜索公众号【IT学长】,后台回复 `“基于web的图书管理系统”`**。 380 | --------------------------------------------------------------------------------