图书管理系统
一、系统介绍
1.软件环境
IDEA:2018.2
Java:jdk1.8
Mysql:8.0.13
Tomcat:8.5.23
2.功能模块图
3.系统功能
1.系统的注册、登录、注销
2.读者信息管理
系统管理员可以对读者信息进行查询、添加、修改、删除等操作。
3.图书信息管理
系统管理员可以对图书信息进行查询、添加、修改、删除等操作。
4.借阅信息管理
管理管理可以对借阅信息进行查询和删除操作,用户可以对借阅信息进行新增、查看操作。
5.个人书架管理
用户对个人书架的新增、删处、查看操作。
6.留言管理
用户可以对留言进行新增、查看操作。
4.数据库表
1.读者表
2.借阅信息表
3.评论留言表
4.图书表
5.书架表
5.工程截图
二、系统展示
1.系统注册
2.系统登录
3.找回密码
4.管理员-主页
5.管理员-用户管理主页
6.管理员-新增用户
7.管理员-修改用户
8.管理员-借阅信息管理
9.管理员-图书管理主页
10.管理员-新增图书
11.管理员-修改图书
12.用户-主页
13.用户-图书明细查看
14.用户-新增留言
15.用户-借阅信息管理
16.用户-书架管理
三、代码实现
Book
packagecom.sjsq.po;importjava.io.Serializable;importjava.util.Date;/**
* @author shuijianshiqing
* @date 2020/5/19 22:40
*/publicclassBookimplementsSerializable{privatestaticfinallong serialVersionUID =1L;privateInteger bookid;privateString bookname;privateDouble price;privateString author;privateString publish;privateInteger categoryid;privateString booklink;privateDate deadline;publicstaticlonggetSerialVersionUID(){return serialVersionUID;}publicIntegergetBookid(){return bookid;}publicvoidsetBookid(Integer bookid){this.bookid = bookid;}publicStringgetBookname(){return bookname;}publicvoidsetBookname(String bookname){this.bookname = bookname;}publicDoublegetPrice(){return price;}publicvoidsetPrice(Double price){this.price = price;}publicStringgetAuthor(){return author;}publicvoidsetAuthor(String author){this.author = author;}publicStringgetPublish(){return publish;}publicvoidsetPublish(String publish){this.publish = publish;}publicIntegergetCategoryid(){return categoryid;}publicvoidsetCategoryid(Integer categoryid){this.categoryid = categoryid;}publicStringgetBooklink(){return booklink;}publicvoidsetBooklink(String booklink){this.booklink = booklink;}publicDategetDeadline(){return deadline;}publicvoidsetDeadline(Date deadline){this.deadline = deadline;}@OverridepublicStringtoString(){return"Book{"+"bookid="+ bookid +", bookname='"+ bookname +'\''+", price="+ price +", author='"+ author +'\''+", publish='"+ publish +'\''+", categoryid="+ categoryid +", booklink='"+ booklink +'\''+", deadline="+ deadline +'}';}}
User
packagecom.sjsq.po;importjava.io.Serializable;/**
* @author shuijianshiqing
* @date 2020/5/19 22:19
* 用户的实体类
*/publicclassUserimplementsSerializable{// 增加序列号,作用是反序列化的时候不会报错,切能进行IO的持久化publicstaticfinallong serialVersionUID =1L;privateInteger userid;privateString username;privateString password;privateString email;privateString phone;privateInteger isadmin;publicstaticlonggetSerialVersionUID(){return serialVersionUID;}publicIntegergetUserid(){return userid;}publicvoidsetUserid(Integer userid){this.userid = userid;}publicStringgetUsername(){return username;}publicvoidsetUsername(String username){this.username = username;}publicStringgetPassword(){return password;}publicvoidsetPassword(String password){this.password = password;}publicStringgetEmail(){return email;}publicvoidsetEmail(String email){this.email = email;}publicStringgetPhone(){return phone;}publicvoidsetPhone(String phone){this.phone = phone;}publicIntegergetIsadmin(){return isadmin;}publicvoidsetIsadmin(Integer isadmin){this.isadmin = isadmin;}@OverridepublicStringtoString(){return"User{"+"userid="+ userid +", username='"+ username +'\''+", password='"+ password +'\''+", email='"+ email +'\''+", phone='"+ phone +'\''+", isadmin="+ isadmin +'}';}}
Record
packagecom.sjsq.po;importjava.util.Date;/**
* @author shuijianshiqing
* @date 2021/5/22 22:05
* 借阅记录实体类
*/publicclassRecord{privateInteger borrowid;privateInteger userid;privateInteger bookid;privateString bookname;privateString booklink;privateDate borrowtime;publicIntegergetBorrowid(){return borrowid;}publicvoidsetBorrowid(Integer borrowid){this.borrowid = borrowid;}publicIntegergetUserid(){return userid;}publicvoidsetUserid(Integer userid){this.userid = userid;}publicIntegergetBookid(){return bookid;}publicvoidsetBookid(Integer bookid){this.bookid = bookid;}publicStringgetBookname(){return bookname;}publicvoidsetBookname(String bookname){this.bookname = bookname;}publicStringgetBooklink(){return booklink;}publicvoidsetBooklink(String booklink){this.booklink = booklink;}publicDategetBorrowtime(){return borrowtime;}publicvoidsetBorrowtime(Date borrowtime){this.borrowtime = borrowtime;}@OverridepublicStringtoString(){return"Record{"+"borrowid="+ borrowid +", userid="+ userid +", bookid="+ bookid +", bookname='"+ bookname +'\''+", booklink='"+ booklink +'\''+", borrowtime="+ borrowtime +'}';}}
Comment
packagecom.sjsq.po;importjava.sql.Time;importjava.util.Date;/**
* @author shuijianshiqing
* @date 2021/5/22 17:18
*
* 留言表
*/publicclassComment{privateInteger commentid;privateInteger userid;privateString username;privateInteger bookid;privateString bookname;privateString comment;privateDate time;publicIntegergetCommentid(){return commentid;}publicvoidsetCommentid(Integer commentid){this.commentid = commentid;}publicIntegergetUserid(){return userid;}publicvoidsetUserid(Integer userid){this.userid = userid;}publicStringgetUsername(){return username;}publicvoidsetUsername(String username){this.username = username;}publicIntegergetBookid(){return bookid;}publicvoidsetBookid(Integer bookid){this.bookid = bookid;}publicStringgetBookname(){return bookname;}publicvoidsetBookname(String bookname){this.bookname = bookname;}publicStringgetComment(){return comment;}publicvoidsetComment(String comment){this.comment = comment;}publicDategetTime(){return time;}publicvoidsetTime(Date time){this.time = time;}@OverridepublicStringtoString(){return"Comment{"+"commentid="+ commentid +", userid="+ userid +", username='"+ username +'\''+", bookid="+ bookid +", bookname='"+ bookname +'\''+", comment='"+ comment +'\''+", time="+ time +'}';}}
BookShelf
packagecom.sjsq.po;importjava.util.Date;/**
* @author shuijianshiqing
* @date 2021/5/22 12:21
* 书架类
*/publicclassBookShelf{privateInteger id;privateInteger userid;privateInteger bookid;privateString bookname;privateString booklink;privateDate adddate;privateDate removedate;publicIntegergetId(){return id;}publicvoidsetId(Integer id){this.id = id;}publicIntegergetUserid(){return userid;}publicvoidsetUserid(Integer userid){this.userid = userid;}publicIntegergetBookid(){return bookid;}publicvoidsetBookid(Integer bookid){this.bookid = bookid;}publicStringgetBookname(){return bookname;}publicvoidsetBookname(String bookname){this.bookname = bookname;}publicStringgetBooklink(){return booklink;}publicvoidsetBooklink(String booklink){this.booklink = booklink;}publicDategetAdddate(){return adddate;}publicvoidsetAdddate(Date adddate){this.adddate = adddate;}publicDategetRemovedate(){return removedate;}publicvoidsetRemovedate(Date removedate){this.removedate = removedate;}@OverridepublicStringtoString(){return"BookShelf{"+"id="+ id +", userid="+ userid +", bookid="+ bookid +", bookname='"+ bookname +'\''+", booklink='"+ booklink +'\''+", adddate="+ adddate +", removedate="+ removedate +'}';}}
BookDao
packagecom.sjsq.dao;importcom.sjsq.po.Book;importjava.util.List;/**
* @author shuijianshiqing
* @date 2020/5/20 23:13
* 图书信息接口
*/publicinterfaceBookDao{/**
* 查询图书信息
* @param sql
* @param arr
* @return
*/publicList<Book>select(String sql,Object[] arr);/**
* 根据图书编号进行查询
* @param bookid
* @return
*/publicBookgetBook(Integer bookid);/**
* 图书新增
* @param book
* @return
*/publicbooleanaddBook(Book book);/**
* 图书修改
* @param book
* @return
*/publicbooleanupdateBook(Book book);/**
* 删除图书
* @param bookid
* @return
*/publicbooleandeleteBook(Integer bookid);}
BookShelfDao
packagecom.sjsq.dao;importcom.sjsq.po.BookShelf;importjava.util.List;/**
* @author shuijianshiqing
* @date 2021/5/22 12:23
*/publicinterfaceBookShelfDao{/**
* 按照用户名检索书架
* @param userid
* @return
*/publicList<BookShelf>selectBookShelf(Integer userid);/**
* 加入书架
* @param bookShelf
* @return
*/publicbooleanaddBookShelf(BookShelf bookShelf);/**
* 移出书架
* @param userid
* @param bookid
* @return
*/publicbooleanremoveBookShelf(Integer userid,Integer bookid);}
CommentDao
packagecom.sjsq.dao;importcom.sjsq.po.Comment;importjava.util.List;/**
* @author shuijianshiqing
* @date 2021/5/22 17:21
*/publicinterfaceCommentDao{/**
* 添加留言
* @param comment
* @return
*/publicbooleanaddComment(Comment comment);/**
* 展示留言
* @param bookid
* @return
*/publicList<Comment>selectComment(Integer bookid);}
RecordDao
packagecom.sjsq.dao;importcom.sjsq.po.Record;importjava.util.List;/**
* @author shuijianshiqing
* @date 2021/5/22 22:07
*/publicinterfaceRecordDao{/**
* 查询所有借阅信息
* @return
*/publicList<Record>selectRecords();/**
* 查询借阅信息
* @return
*/publicList<Record>selectRecord(Integer userid);/**
* 新增借阅记录
* @param record
* @return
*/publicbooleanaddRecord(Recordrecord);/**
* 删除借阅记录
* @param borrowid
* @return
*/publicbooleandeleteRecord(Integer borrowid);}
UserDao
packagecom.sjsq.dao;importcom.sjsq.po.User;importjava.util.List;/**
* @author shuijianshiqing
* @date 2020/5/20 22:10
* 创建一个接口用于声明用户登录注册的方法
*/publicinterfaceUserDao{/**
* 用户登录
* @param user
* @return
*/publicUserlogin(User user);/**
* 用户注册
* @param user
* @return
*/publicbooleanregister(User user);/**
* 查询用户信息
* @param sql
* @param arr
* @return
*/publicList<User>selectUser(String sql,Object arr[]);/**
* 根据用户编号进行查询
* @param userid
* @return
*/publicUsergetUser(Integer userid);/**
* 新增用户
* @param user
* @return
*/publicbooleanaddUser(User user);/**
* 修改用户
* @param user
* @return
*/publicbooleanupdateUser(User user);/**
* 删除用户
* @param userid
* @return
*/publicbooleandeleteUser(Integer userid);}
BookService
packagecom.sjsq.service;importcom.sjsq.po.Book;importjava.util.List;/**
* @author shuijianshiqing
* @date 2020/5/20 23:37
* Book的Service层
*/publicinterfaceBookService{/**
* 查询图书信息
* @param bookname
* @return
*/publicList<Book>select(String bookname);/**
* 根据图书编号进行查询
* @param id
* @return
*/publicBookgetBook(Integer id);/**
* 图书新增
* @param book
* @return
*/publicbooleanaddBook(Book book);/**
* 图书修改
* @param book
* @return
*/publicbooleanupdateBook(Book book);/**
* 删除图书
* @param bookid
* @return
*/publicbooleandeleteBook(Integer bookid);}
BookShelfService
packagecom.sjsq.service;importcom.sjsq.po.BookShelf;importjava.util.List;/**
* @author shuijianshiqing
* @date 2021/5/22 12:36
*/publicinterfaceBookShelfService{/**
* 按照用户名检索书架
* @param userid
* @return
*/publicList<BookShelf>selectBookShelf(Integer userid);/**
* 加入书架
* @param bookShelf
* @return
*/publicbooleanaddBookShelf(BookShelf bookShelf);/**
* 移出书架
* @param userid
* @param bookid
* @return
*/publicbooleanremoveBookShelf(Integer userid,Integer bookid);}
CommentService
packagecom.sjsq.service;importcom.sjsq.po.Comment;importjava.util.List;/**
* @author shuijianshiqing
* @date 2021/5/22 17:21
*/publicinterfaceCommentService{/**
* 添加留言
* @param comment
* @return
*/publicbooleanaddComment(Comment comment);/**
* 展示留言
* @param bookid
* @return
*/publicList<Comment>selectComment(Integer bookid);}
RecordService
packagecom.sjsq.service;importcom.sjsq.po.Record;importjava.util.List;/**
* @author shuijianshiqing
* @date 2021/5/22 22:17
*/publicinterfaceRecordService{/**
* 查询所有借阅信息
* @return
*/publicList<Record>selectRecords();/**
* 查询借阅信息
* @return
*/publicList<Record>selectRecord(Integer userid);/**
* 新增借阅记录
* @param record
* @return
*/publicbooleanaddRecord(Recordrecord);/**
* 删除借阅记录
* @param borrowid
* @return
*/publicbooleandeleteRecord(Integer borrowid);}
login.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
// 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":"
+ request.getServerPort() + path + "/";
%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><basehref="<%=basePath %>"/><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>用户登录</title><styletype="text/css">h1{text-align: center;}h4{text-align: center;color: red;}body{background-color: antiquewhite;}a{text-decoration: none;font-size: 20px;color: black;}a:hover{text-decoration: underline;font-size: 24px;color: red;}</style></head><body><formaction="login-do-info.jsp"method="post"><h1>用户登录</h1><hr/><tablealign="center"><tr><td>账号:</td><td><inputtype="text"name="username"id="username"placeholder="请输入您的账号"autofocus="autofocus"></td></tr><tr><td>密码:</td><td><inputtype="password"name="password"id="password"placeholder="请输入您的密码"></td><td><ahref="search-password.jsp">找回密码</a></td></tr><tr><tdcolspan="1"></td><td><inputtype="submit"value="登录"/><inputtype="reset"value="重置"/><ahref="register.jsp"target="_blank">注册</a></td></tr></table></form></body></html>
login-do-info.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.sjsq.dao.UserDao" %>
<%@ page import="com.sjsq.dao.impl.UserDaoImpl" %>
<%@ page import="com.sjsq.po.User" %>
<%@ page import="com.sjsq.service.UserService" %>
<%@ page import="com.sjsq.service.impl.UserServiceImpl" %>
<%@ page import="java.util.List" %>
<%
// 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":"
+ request.getServerPort() + path + "/";
%>
<!DOCTYPEhtmlPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN""http://www.w3.org/TR/html4/loose.dtd"><html><head><basehref="<%=basePath %>"/><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>用户登录</title><styletype="text/css">h1{text-align: center;}h4{text-align: center;color: red;}body{background-color: antiquewhite;}</style></head><body><h1>现存图书列表</h1><hr>
<%
// 设置接收的编码为UTF-8
request.setCharacterEncoding("utf-8");
User user = new User();
UserDao dao = new UserDaoImpl();
String username = request.getParameter("username");
String password = request.getParameter("password");
user.setUsername(username);
user.setPassword(password);
// 获取用户登录信息
User us = dao.login(user);
// 把数据库里面的User获取出来
UserService service = new UserServiceImpl();
List<User> list = service.selectUser(username);
for (int i = 0; i < list.size(); i++) {
user = list.get(i);
}
System.out.println("----us的信息----");
System.out.println(us);
// 设置会话
session.setAttribute("user", user);
// 这里要对us判空处理,1是管理者,0是学生,此处的isadmin必须填写不能为空。
if (us != null && us.getIsadmin().equals(1)) {
response.sendRedirect("admin-home.jsp");
} else if (us != null && !us.getIsadmin().equals(1)) {
response.sendRedirect("user-home.jsp");
} else {
response.sendRedirect("login-fail.jsp");
}
%>
</body></html>
login-fail.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>登录失败</title><styletype="text/css">h1{text-align: center;}h4{text-align: center;color: red;}body{background-color: antiquewhite;}div{text-align: center;}</style></head><body><h1>登录失败</h1><hr><div><ahref="login.jsp">返回登录</a></div></body></html>
logout.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>退出登录</title></head><body>
<%
// 杀掉会话
session.invalidate();
// 重定向,地址栏的链接会发生改变
response.sendRedirect("login.jsp");
%>
</body></html>
register.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPEhtml><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>用户注册</title><styletype="text/css">h1{text-align: center;}h4{text-align: center;color: red;}body{background-color: antiquewhite;}div{text-align: center;}</style></head><body><h1>用户注册</h1><hr/><formaction="register-do.jsp"method="post"name="registerForm"><div><tr><label>您的账号:</label><inputtype="text"name="name"id="name"placeholder="请输入用户名"></tr></div><div><tr><label>您的密码:</label><inputtype="password"name="password"id="password"placeholder="请输入密码"></tr></div><div><tr><label>确认密码:</label><inputtype="password"name="relpassword"id="relpassword"placeholder="请确认密码"></tr></div><div><tr><label>电话号码:</label><inputtype="text"name="phone"id="phone"placeholder="请输入电话号码"></tr></div><div><tr><label>电子邮件:</label><inputtype="text"name="email"id="email"placeholder="请输入电子邮件"></tr></div><div><tr><buttontype="submit"onclick="return checkForm()">注册</button><buttontype="reset">重置</button><ahref="login.jsp"target="_blank">登录</a></tr></div></form><scripttype="text/javascript">functioncheckForm(){var name = registerForm.name.value;var pwd = registerForm.password.value;var repwd = registerForm.relpassword.value;//alert(name + pwd + repwd);if(name ==""|| name ==null){alert("请输入用户名");
registerForm.name.focus();returnfalse;}elseif(pwd ==""|| pwd ==null){alert("请输入密码");
registerForm.password.focus();returnfalse;}elseif(repwd ==""|| repwd ==null){alert("请输入确认密码");
registerForm.relpassword.focus();returnfalse;}elseif(pwd != repwd){alert("两次密码输入不一致,请重新输入!");
registerForm.relpassword.focus();returnfalse;}alert('注册成功!');returntrue;}</script></body></html>
register-do.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8"%>
<%@page import="com.sjsq.dao.impl.UserDaoImpl"%>
<%@page import="com.sjsq.dao.UserDao"%>
<%@page import="com.sjsq.po.User"%>
<!DOCTYPEhtml><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>处理注册</title></head><body>
<%
// 设置获取注册时的编码为UTF-8
request.setCharacterEncoding("UTF-8");
User user=new User();
//获取register.jsp页面提交的账号和密码
String name=request.getParameter("name");
String password=request.getParameter("password");
String email=request.getParameter("email");
String phone=request.getParameter("phone");
//获取register.jsp页面提交的账号和密码设置到实体类User中
user.setUsername(name);
user.setPassword(password);
user.setEmail(email);
user.setPhone(phone);
//引入数据交互层
UserDao dao=new UserDaoImpl();
boolean flag=dao.register(user);
if(flag){
response.sendRedirect("login.jsp");
}else{
response.sendRedirect("register.jsp");
}
%>
</body></html>
search-password.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
// 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":"
+ request.getServerPort() + path + "/";
%>
<!DOCTYPEhtml><html><head><basehref="<%=basePath %>"/><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>找回密码</title><styletype="text/css">h1{text-align: center;}div{text-align: center;}body{background-color:antiquewhite;}</style></head><body><h1>找回密码</h1><hr><div><ahref="javascript: window.history.go(-1)">返回上一级</a></div><br><formaction="search-password-do.jsp"method="post"><tablealign="center"><tr><td>请输入账号:</td><td><inputtype="text"name="name"/></td></tr><tr><tdcolspan="1"></td><td><inputtype="submit"value="提交"><inputtype="reset"value="重置"></td></tr></table></form></body></html>
search-password-do.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@page import="java.util.List"%>
<%@page import="com.sjsq.service.impl.UserServiceImpl"%>
<%@page import="com.sjsq.po.User"%>
<%
// 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":"
+ request.getServerPort() + path + "/";
%>
<!DOCTYPEhtml><html><head><basehref="<%=basePath %>"/><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>处理找回密码</title></head><body>
<%
User user=new User();
//获取searchPassword.jsp页面提交的账号和密码
String name=request.getParameter("name");
user.setUsername(name);
UserServiceImpl service=new UserServiceImpl();
List<User> list=service.selectUser(user);
request.setAttribute("list", list);
for(User u:list){
request.setAttribute("user", u);
out.print(u);
}
if(user!=null){
request.getRequestDispatcher("search-password-info.jsp").forward(request, response);
}
%>
</body></html>
search-password-info.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%
// 获取绝对路径路径 ,开发项目一定要使用绝对路径,不然肯定出错
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":"
+ request.getServerPort() + path + "/";
%>
<!DOCTYPEhtml><html><head><basehref="<%=basePath %>"/><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>弹出信息</title><scripttype="text/javascript">alert("您的密码是:${user.password}");</script><styletype="text/css">h1{text-align: center;}div{text-align: center;}</style></head><body><h1>您的密码是:${user.password}</h1><div><td><ahref="login.jsp">返回登录</a></td></div></body></html>
admin-home.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<!DOCTYPEhtml><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>管理员主页</title><styletype="text/css">body{background-color: antiquewhite;text-align: center;}</style></head><body>
<%-- 头部 --%>
<jsp:includepage="top.jsp"/><h1>欢迎来到图书管理系统</h1><hr><h4>管理员操作</h4><ahref="admin-user-manager.jsp">管理用户</a><ahref="admin-book-manager.jsp">管理图书</a></body></html>
admin-book-add.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPEhtml><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>新增图书</title><styletype="text/css">h1{text-align: center;}h4{text-align: center;color: red;}body{background-color: antiquewhite;}div{text-align: center;}#before{text-align: center;}</style></head><body>
<%-- 头部 --%>
<jsp:includepage="top.jsp"/><h1>新增图书</h1><hr><divid="before"><ahref="javascript: window.history.go(-1)">返回上一级</a></div></br><formaction="admin-book-do-add.jsp"method="post"name="registerForm"><div><tr><label>图书名称:</label><inputtype="text"name="bookname"id="bookname"placeholder="图书名称"autofocus="autofocus"></tr></div><div><tr><label>图书价格:</label></td><inputtype="text"name="price"id="price"placeholder="图书价格(数字)"></tr></div><div><tr><label>图书作者:</label><inputtype="text"name="author"id="author"placeholder="图书作者"></tr></div><div><tr><label>出版公司:</label><inputtype="text"name="publish"id="publish"placeholder="出版公司"></tr></div><div><tr><label>类型编号:</label><inputtype="text"name="categoryid"id="categoryid"placeholder="类型编号"></tr></div><div><tr><label>书籍链接:</label><inputtype="text"name="booklink"id="booklink"placeholder="书籍链接"></tr></div><divid="submitbtn"><tr><buttontype="submit"onclick="return checkForm()">添加</button><buttontype="reset">重置</button></tr></div></form><scripttype="text/javascript">functioncheckForm(){var bookname = registerForm.bookname.value;var price = registerForm.price.value;if(bookname ==""|| bookname ==null){alert("请输入图书名称");
registerForm.bookname.focus();returnfalse;}elseif(price ==""|| price ==null){alert("请输入图书价格");
registerForm.price.focus();returnfalse;}alert('添加成功!');returntrue;}</script></body></html>
admin-book-delete.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.sjsq.dao.BookDao" %>
<%@ page import="com.sjsq.dao.impl.BookDaoImpl" %>
<%@ page import="com.sjsq.po.Book" %>
<%@ page import="com.sjsq.service.BookService" %>
<%@ page import="com.sjsq.service.impl.BookServiceImpl" %>
<html><head><title>删除图书</title><styletype="text/css">#before{text-align: center;}body{background-color: antiquewhite;}</style></head><body>
<%-- 头部 --%>
<jsp:includepage="top.jsp"/>
<%
// 设置获取注册时的编码为UTF-8
request.setCharacterEncoding("UTF-8");
//获取admin.jsp页面的bookid
Integer bookid = Integer.parseInt(request.getParameter("bookid"));
//引入数据交互层
BookService bookService = new BookServiceImpl();
Book book = new Book();
book = bookService.getBook(bookid);
System.out.println("删除的图书信息:");
System.out.println(book);
boolean flag = bookService.deleteBook(bookid);
if (flag) {
response.sendRedirect("admin-book-manager.jsp");
} else {
response.sendRedirect("error.jsp");
}
%>
</body></html>
admin-book-update.jsp
<%@ page import="com.sjsq.dao.BookDao" %>
<%@ page import="com.sjsq.dao.impl.BookDaoImpl" %>
<%@ page import="com.sjsq.po.Book" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPEhtml><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>修改图书</title><styletype="text/css">h1{text-align: center;}h4{text-align: center;color: red;}body{background-color: antiquewhite;}div{text-align: center;}</style></head><body>
<%-- 头部 --%>
<jsp:includepage="top.jsp"/><h1>修改图书</h1><hr/>
<%
//获取admin-home.jsp页面的bookid
Integer bookid = Integer.parseInt(request.getParameter("bookid"));
BookDao dao = new BookDaoImpl();
Book book = new Book();
book = dao.getBook(bookid);
%>
<formaction="admin-book-do-update.jsp"method="post"name="registerForm"><div><tr><inputtype="hidden"name="bookid"id="bookid"value="<%=book.getBookid()%>"></tr></div><div><tr><label>图书名称:</label><inputtype="text"name="bookname"id="bookname"value="<%=book.getBookname()%>"autofocus="autofocus"></tr></div><div><tr><label>图书价格:</label></td><inputtype="text"name="price"id="price"value="<%=book.getPrice()%>"></tr></div><div><tr><label>图书作者:</label><inputtype="text"name="author"id="author"value="<%=book.getAuthor()%>"></tr></div><div><tr><label>出版公司:</label><inputtype="text"name="publish"id="publish"value="<%=book.getPublish()%>"></tr></div><div><tr><label>类型编号:</label><inputtype="text"name="categoryid"id="categoryid"value="<%=book.getCategoryid()%>"></tr></div><div><tr><label>书籍链接:</label><inputtype="text"name="booklink"id="booklink"value="<%=book.getBooklink()%>"></tr></div><div><tr><buttontype="submit"onclick="return checkForm()">修改</button><buttontype="reset">重置</button></tr></div></form><scripttype="text/javascript">functioncheckForm(){var bookname = registerForm.bookname.value;var price = registerForm.price.value;//alert(name + pwd + repwd);if(bookname ==""|| bookname ==null){alert("请输入图书名称");
registerForm.bookname.focus();returnfalse;}elseif(price ==""|| price ==null){alert("请输入图书价格");
registerForm.price.focus();returnfalse;}alert('修改成功!');returntrue;}</script></body></html>
admin-user-add.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPEhtml><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>新增用户</title><styletype="text/css">h1{text-align: center;}h4{text-align: center;color: red;}body{background-color: antiquewhite;}div{text-align: center;}#before{text-align: center;}</style></head><body>
<%-- 头部 --%>
<jsp:includepage="top.jsp"/><h1>新增用户</h1><hr><divid="before"><ahref="javascript: window.history.go(-1)">返回上一级</a></div></br><formaction="admin-user-do-add.jsp"method="post"name="registerForm"><div><tr><label>账号:</label><inputtype="text"name="username"id="username"placeholder="用户名"autofocus="autofocus"></tr></div><div><tr><label>密码:</label></td><inputtype="text"name="password"id="password"placeholder="密码"></tr></div><div><tr><label>邮箱:</label><inputtype="text"name="email"id="email"placeholder="邮箱"></tr></div><div><tr><label>电话:</label><inputtype="text"name="phone"id="phone"placeholder="电话"></tr></div><div><tr><label>是否管理员:</label><inputtype="text"name="isadmin"id="isadmin"placeholder="是否管理员(1是,0否)"></tr></div><divid="submitbtn"><tr><buttontype="submit"onclick="return checkForm()">添加</button><buttontype="reset">重置</button></tr></div></form><scripttype="text/javascript">functioncheckForm(){var username = registerForm.username.value;var password = registerForm.password.value;if(username ==""|| username ==null){alert("请输入用户名");
registerForm.username.focus();returnfalse;}elseif(password ==""|| password ==null){alert("请输入密码");
registerForm.password.focus();returnfalse;}alert('添加成功!');returntrue;}</script></body></html>
admin-user-delete.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.sjsq.po.User" %>
<%@ page import="com.sjsq.service.UserService" %>
<%@ page import="com.sjsq.service.impl.UserServiceImpl" %>
<html><head><title>删除用户</title><styletype="text/css">#before{text-align: center;}body{background-color: antiquewhite;}</style></head><body>
<%-- 头部 --%>
<jsp:includepage="top.jsp"/>
<%
// 设置获取注册时的编码为UTF-8
request.setCharacterEncoding("UTF-8");
//获取admin-user-manager.jsp页面的userid
Integer userid = Integer.parseInt(request.getParameter("userid"));
//引入数据交互层
UserService userService = new UserServiceImpl();
// 获取删除用户的信息
User user = userService.getUser(userid);
System.out.println("删除的用户信息:"+user);
boolean flag = userService.deleteUser(userid);
if (flag) {
response.sendRedirect("admin-user-manager.jsp");
} else {
response.sendRedirect("error.jsp");
}
%>
</body></html>
admin-user-update.jsp
<%@ page import="com.sjsq.po.User" %>
<%@ page import="com.sjsq.service.UserService" %>
<%@ page import="com.sjsq.service.impl.UserServiceImpl" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPEhtml><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>修改用户</title><styletype="text/css">h1{text-align: center;}h4{text-align: center;color: red;}body{background-color: antiquewhite;}div{text-align: center;}</style></head><body>
<%-- 头部 --%>
<jsp:includepage="top.jsp"/><h1>修改用户</h1><hr/>
<%
//获取admin-user-home.jsp页面的userid
Integer userid = Integer.parseInt(request.getParameter("userid"));
UserService userService = new UserServiceImpl();
User user = userService.getUser(userid);
%>
<formaction="admin-user-do-update.jsp"method="post"name="registerForm"><div><tr><label>编号:</label><inputtype="text"name="userid"id="userid"readonly="readonly"value="<%=user.getUserid()%>"></tr></div><div><tr><label>用户:</label><inputtype="text"name="username"id="username"readonly="readonly"value="<%=user.getUsername()%>"></tr></div><div><tr><label>密码:</label><inputtype="text"name="password"id="password"value="<%=user.getPassword()%>"></tr></div><div><tr><label>邮箱:</label><inputtype="text"name="email"id="email"value="<%=user.getEmail()%>"></tr></div><div><tr><label>电话:</label><inputtype="text"name="phone"id="phone"value="<%=user.getPhone()%>"></tr></div><div><tr><label>是否管理员:</label><inputtype="text"name="isadmin"id="isadmin"value="<%=user.getIsadmin()%>"></tr></div><div><tr><buttontype="submit"onclick="return checkForm()">修改</button><buttontype="reset">重置</button></tr></div></form><scripttype="text/javascript">functioncheckForm(){var password = registerForm.password.value;if(password ==""|| password ==null){alert("请输入密码");
registerForm.password.focus();returnfalse;}alert('修改成功!');returntrue;}</script></body></html>
user-home.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.sjsq.po.Book" %>
<%@ page import="com.sjsq.service.impl.BookServiceImpl" %>
<%@ page import="java.util.List" %>
<!DOCTYPEhtml><html><head><metahttp-equiv="Content-Type"content="text/html; charset=UTF-8"><title>查看图书</title><styletype="text/css">h1{text-align: center;}#before{text-align: center;}</style></head><body>
<%-- 头部 --%>
<jsp:includepage="user-top.jsp"/>
<%--图书信息--%>
<%
// 获取上一个页面传过来的值
String bookname = request.getParameter("bookname");
System.out.println("书名:" + bookname);
// 传入的空字符串处理,null不能使用equals
if (bookname != null && bookname.equals("")) {
bookname = null;
}
BookServiceImpl service = new BookServiceImpl();
List<Book> list = service.select(bookname);
%>
<h1>图书列表</h1><hr><divid="before"><formaction="user-home.jsp"method="post">
请输入书名:<inputtype="text"name="bookname"placeholder="输入图书名称搜索"><inputtype="submit"value="查询"/></form><ahref="javascript: window.history.go(-1)">返回上一级</a></div><br><tablealign="center"cellspacing="0"><trbgcolor="#5f9ea0"style="font-size: 20px;height:40px;text-align: center"><tdstyle="width: 120px">编号</td><tdstyle="width: 120px">书名</td><tdstyle="width: 120px">价格</td><tdstyle="width: 120px">作者</td><tdstyle="width: 120px">出版社</td></tr>
<%
String bg = null;
for (int i = 0; i < list.size(); i++) {
Book b = list.get(i);
if (i % 2 == 0) {
bg = "pink";
} else {
bg = "yellow";
}
%>
<trbgcolor="<%=bg%>"style="height:40px;text-align: center"><td><%=b.getBookid()%>
</td><td><ahref="user-book-info.jsp?bookid=<%=b.getBookid()%>"><%=b.getBookname()%>
</a></td><td><%=b.getPrice() %>
</td><td><%=b.getAuthor() %>
</td><td><%=b.getPublish() %>
</td></tr>
<%
}
%>
</table></body></html>
user-comment-add.jsp
<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<%@ page import="com.sjsq.po.User" %>
<%@ page import="com.sjsq.service.BookShelfService" %>
<%@ page import="com.sjsq.service.impl.BookShelfServiceImpl" %>
<%@ page import="com.sjsq.po.BookShelf" %>
<%@ page import="com.sjsq.po.Book" %>
<%@ page import="com.sjsq.service.BookService" %>
<%@ page import="com.sjsq.service.impl.BookServiceImpl" %>
<%@ page import="com.sjsq.service.CommentService" %>
<%@ page import="com.sjsq.service.impl.CommentServiceImpl" %>
<%@ page import="com.sjsq.po.Comment" %>
<html><head><title>加入书架</title><styletype="text/css">body{background-color: antiquewhite;}</style></head><body>
<%-- 头部 --%>
<jsp:includepage="top.jsp"/>
<%
// 设置获取注册时的编码为UTF-8
request.setCharacterEncoding("UTF-8");
// 获取user信息
User user =(User)session.getAttribute("user");
Integer userid = user.getUserid();
String username = user.getUsername();
//获取book信息
Integer bookid = Integer.parseInt(request.getParameter("bookid"));
BookService bookService = new BookServiceImpl();
Book book = bookService.getBook(bookid);
String bookname = book.getBookname();
String content = request.getParameter("content");
Comment comment = new Comment();
comment.setUserid(userid);
comment.setUsername(username);
comment.setBookid(bookid);
comment.setBookname(bookname);
comment.setComment(content);
session.setAttribute("bookid",bookid);
//引入数据交互层
CommentService commentService = new CommentServiceImpl();
boolean flag = commentService.addComment(comment);
if (flag) {
response.sendRedirect("user-book-info.jsp");
} else {
response.sendRedirect("error.jsp");
}
%>
</body></html>
四、其他
1.其他系统实现
Java+JSP系统系列实现
Java+JSP实现学生图书管理系统
Java+JSP实现学生信息管理系统
Java+JSP实现用户信息管理系统
Java+Servlet+JSP系统系列实现
Java+Servlet+JSP实现航空订票系统
Java+Servlet+JSP实现新闻发布系统
Java+Servlet+JSP实现图书管理系统
Java+Servlet+JSP实现停车场管理系统
Java+Servlet+JSP实现房屋租赁管理系统
Java+Servlet+JSP实现学生选课管理系统
Java+Servlet+JSP实现宠物诊所管理系统
Java+Servlet+JSP实现学生宿舍管理系统
Java+Servlet+JSP实现学生信息管理系统
Java+Servlet+JSP实现学生成绩管理系统1
Java+Servlet+JSP实现学生成绩管理系统2
Java+SSM系统系列实现
Java+SSM+JSP实现宠物商城系统
Java+SSM+JSP实现超市订单系统
Java+SSM+Easyui实现网上考试系统
Java+SSM+Layui实现学生成绩管理系统
Java+SSM+Bootstrap实现学生信息管理系统
Java+SSM+Bootstrap+Maven实现网上书城系统
Java+SSM+Bootstrap+Maven实现学校教务管理系统
Java+SSH系统系列实现
Java+SSH+Bootstrap实现在线考试系统
Java+SSH+JSP实现医院在线挂号系统
Java+Springboot系统系列实现
Java+Springboot+H-ui实现营销管理系统
Java+Springboot+Bootstrap实现网上商城系统
Java+Springboot+Bootstrap+Maven实现景区旅游管理系统
JavaSwing+Mysql系统系列实现
Java+Swing实现斗地主游戏
Java+Swing实现图书管理系统
Java+Swing实现医院管理系统
Java+Swing实现考试管理系统
Java+Swing实现酒店管理系统
Java+Swing实现超市管理系统
Java+Swing实现网上订餐系统
Java+Swing实现电影购票系统
Java+Swing实现仓库管理系统1
Java+Swing实现仓库管理系统2
Java+Swing实现进销存管理系统
Java+Swing实现通讯录管理系统
Java+Swing实现停车场管理系统
Java+Swing实现学生宿舍管理系统
Java+Swing实现学生选课管理系统
Java+Swing实现学生成绩管理系统
Java+Swing实现学校教材管理系统
Java+Swing实现学校教务管理系统
Java+Swing实现企业人事管理系统
Java+Swing实现电子相册管理系统
Java+Swing实现学生信息管理系统1
Java+Swing实现学生信息管理系统2
Java+Swing实现自助取款机(ATM)系统
JavaSwing+Txt系统系列实现
Java+Swing实现超市管理系统-TXT存储信息
Java+Swing实现宠物商店管理系统-TXT存储信息
Java+Swing实现自助取款机(ATM)系统-TXT存储信息
2.获取源码
点击以下链接获取源码,数据库文件在sql文件下面。
Java+JSP+Mysql实现Web学生图书管理系统
3.功能演示及实现视频
有需要可以关住账号
手把手教你写图书管理系统-第1节-系统功能演示
手把手教你写图书管理系统-第2节-系统功能说明
手把手教你写图书管理系统-第3节-数据库设计
4.备注
如有侵权请联系我删除。
5.联系博主
左侧关注微信公众号,里面有Java教程和一些Java资源。如果此文对您有帮助,请关注加点赞,谢谢!
版权归原作者 水坚石青 所有, 如有侵权,请联系我们删除。