Java+JSP+Mysql+Tomcat实现Web图书管理系统

48 篇文章 0 订阅

图书管理系统

一、系统介绍

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

package com.sjsq.po;

import java.io.Serializable;
import java.util.Date;

/**
 * @author shuijianshiqing
 * @date 2020/5/19 22:40
 */

public class Book implements Serializable {

    private static final long serialVersionUID = 1L;
    private Integer bookid;
    private String bookname;
    private Double price;
    private String author;
    private String publish;
    private Integer categoryid;
    private String booklink;
    private Date deadline;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Integer getBookid() {
        return bookid;
    }

    public void setBookid(Integer bookid) {
        this.bookid = bookid;
    }

    public String getBookname() {
        return bookname;
    }

    public void setBookname(String bookname) {
        this.bookname = bookname;
    }

    public Double getPrice() {
        return price;
    }

    public void setPrice(Double price) {
        this.price = price;
    }

    public String getAuthor() {
        return author;
    }

    public void setAuthor(String author) {
        this.author = author;
    }

    public String getPublish() {
        return publish;
    }

    public void setPublish(String publish) {
        this.publish = publish;
    }

    public Integer getCategoryid() {
        return categoryid;
    }

    public void setCategoryid(Integer categoryid) {
        this.categoryid = categoryid;
    }

    public String getBooklink() {
        return booklink;
    }

    public void setBooklink(String booklink) {
        this.booklink = booklink;
    }

    public Date getDeadline() {
        return deadline;
    }

    public void setDeadline(Date deadline) {
        this.deadline = deadline;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bookid=" + bookid +
                ", bookname='" + bookname + ''' +
                ", price=" + price +
                ", author='" + author + ''' +
                ", publish='" + publish + ''' +
                ", categoryid=" + categoryid +
                ", booklink='" + booklink + ''' +
                ", deadline=" + deadline +
                '}';
    }
}

User

package com.sjsq.po;

import java.io.Serializable;

/**
 * @author shuijianshiqing
 * @date 2020/5/19 22:19
 * 用户的实体类
 */

public class User implements Serializable {

    // 增加序列号,作用是反序列化的时候不会报错,切能进行IO的持久化
    public static final long serialVersionUID = 1L;
    private Integer userid;
    private String username;
    private String password;
    private String email;
    private String phone;
    private Integer isadmin;

    public static long getSerialVersionUID() {
        return serialVersionUID;
    }

    public Integer getUserid() {
        return userid;
    }

    public void setUserid(Integer userid) {
        this.userid = userid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public String getPassword() {
        return password;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getPhone() {
        return phone;
    }

    public void setPhone(String phone) {
        this.phone = phone;
    }

    public Integer getIsadmin() {
        return isadmin;
    }

    public void setIsadmin(Integer isadmin) {
        this.isadmin = isadmin;
    }

    @Override
    public String toString() {
        return "User{" +
                "userid=" + userid +
                ", username='" + username + ''' +
                ", password='" + password + ''' +
                ", email='" + email + ''' +
                ", phone='" + phone + ''' +
                ", isadmin=" + isadmin +
                '}';
    }
}

Record

package com.sjsq.po;

import java.util.Date;

/**
 * @author shuijianshiqing
 * @date 2021/5/22 22:05
 * 借阅记录实体类
 */
public class Record {

    private Integer borrowid;
    private Integer userid;
    private Integer bookid;
    private String bookname;
    private String booklink;
    private Date borrowtime;

    public Integer getBorrowid() {
        return borrowid;
    }

    public void setBorrowid(Integer borrowid) {
        this.borrowid = borrowid;
    }

    public Integer getUserid() {
        return userid;
    }

    public void setUserid(Integer userid) {
        this.userid = userid;
    }

    public Integer getBookid() {
        return bookid;
    }

    public void setBookid(Integer bookid) {
        this.bookid = bookid;
    }

    public String getBookname() {
        return bookname;
    }

    public void setBookname(String bookname) {
        this.bookname = bookname;
    }

    public String getBooklink() {
        return booklink;
    }

    public void setBooklink(String booklink) {
        this.booklink = booklink;
    }

    public Date getBorrowtime() {
        return borrowtime;
    }

    public void setBorrowtime(Date borrowtime) {
        this.borrowtime = borrowtime;
    }

    @Override
    public String toString() {
        return "Record{" +
                "borrowid=" + borrowid +
                ", userid=" + userid +
                ", bookid=" + bookid +
                ", bookname='" + bookname + ''' +
                ", booklink='" + booklink + ''' +
                ", borrowtime=" + borrowtime +
                '}';
    }
}

Comment

package com.sjsq.po;

import java.sql.Time;
import java.util.Date;

/**
 * @author shuijianshiqing
 * @date 2021/5/22 17:18
 *
 * 留言表
 */
public class Comment {

    private Integer commentid;
    private Integer userid;
    private String username;
    private Integer bookid;
    private String bookname;
    private String comment;
    private Date time;

    public Integer getCommentid() {
        return commentid;
    }

    public void setCommentid(Integer commentid) {
        this.commentid = commentid;
    }

    public Integer getUserid() {
        return userid;
    }

    public void setUserid(Integer userid) {
        this.userid = userid;
    }

    public String getUsername() {
        return username;
    }

    public void setUsername(String username) {
        this.username = username;
    }

    public Integer getBookid() {
        return bookid;
    }

    public void setBookid(Integer bookid) {
        this.bookid = bookid;
    }

    public String getBookname() {
        return bookname;
    }

    public void setBookname(String bookname) {
        this.bookname = bookname;
    }

    public String getComment() {
        return comment;
    }

    public void setComment(String comment) {
        this.comment = comment;
    }

    public Date getTime() {
        return time;
    }

    public void setTime(Date time) {
        this.time = time;
    }

    @Override
    public String toString() {
        return "Comment{" +
                "commentid=" + commentid +
                ", userid=" + userid +
                ", username='" + username + ''' +
                ", bookid=" + bookid +
                ", bookname='" + bookname + ''' +
                ", comment='" + comment + ''' +
                ", time=" + time +
                '}';
    }
}

BookShelf

package com.sjsq.po;

import java.util.Date;

/**
 * @author shuijianshiqing
 * @date 2021/5/22 12:21
 * 书架类
 */
public class BookShelf {
    private Integer id;
    private Integer userid;
    private Integer bookid;
    private String bookname;
    private String booklink;
    private Date adddate;
    private Date removedate;

    public Integer getId() {
        return id;
    }

    public void setId(Integer id) {
        this.id = id;
    }

    public Integer getUserid() {
        return userid;
    }

    public void setUserid(Integer userid) {
        this.userid = userid;
    }

    public Integer getBookid() {
        return bookid;
    }

    public void setBookid(Integer bookid) {
        this.bookid = bookid;
    }

    public String getBookname() {
        return bookname;
    }

    public void setBookname(String bookname) {
        this.bookname = bookname;
    }

    public String getBooklink() {
        return booklink;
    }

    public void setBooklink(String booklink) {
        this.booklink = booklink;
    }

    public Date getAdddate() {
        return adddate;
    }

    public void setAdddate(Date adddate) {
        this.adddate = adddate;
    }

    public Date getRemovedate() {
        return removedate;
    }

    public void setRemovedate(Date removedate) {
        this.removedate = removedate;
    }

    @Override
    public String toString() {
        return "BookShelf{" +
                "id=" + id +
                ", userid=" + userid +
                ", bookid=" + bookid +
                ", bookname='" + bookname + ''' +
                ", booklink='" + booklink + ''' +
                ", adddate=" + adddate +
                ", removedate=" + removedate +
                '}';
    }
}

BookDao

package com.sjsq.dao;

import com.sjsq.po.Book;

import java.util.List;

/**
 * @author shuijianshiqing
 * @date 2020/5/20 23:13
 * 图书信息接口
 */

public interface BookDao {

    /**
     * 查询图书信息
     * @param sql
     * @param arr
     * @return
     */
    public List<Book> select(String sql, Object[] arr);

    /**
     * 根据图书编号进行查询
     * @param bookid
     * @return
     */
    public Book getBook(Integer bookid);


    /**
     * 图书新增
     * @param book
     * @return
     */
    public boolean addBook(Book book);

    /**
     * 图书修改
     * @param book
     * @return
     */
    public boolean updateBook(Book book);

    /**
     * 删除图书
     * @param bookid
     * @return
     */
    public boolean deleteBook(Integer bookid);
}

BookShelfDao

package com.sjsq.dao;

import com.sjsq.po.BookShelf;

import java.util.List;

/**
 * @author shuijianshiqing
 * @date 2021/5/22 12:23
 */
public interface BookShelfDao {


    /**
     * 按照用户名检索书架
     * @param userid
     * @return
     */
    public List<BookShelf> selectBookShelf(Integer userid);


    /**
     * 加入书架
     * @param bookShelf
     * @return
     */
    public boolean addBookShelf(BookShelf bookShelf);


    /**
     * 移出书架
     * @param userid
     * @param bookid
     * @return
     */
    public boolean removeBookShelf(Integer userid,Integer bookid);
}

CommentDao

package com.sjsq.dao;

import com.sjsq.po.Comment;

import java.util.List;

/**
 * @author shuijianshiqing
 * @date 2021/5/22 17:21
 */
public interface CommentDao {

    /**
     * 添加留言
     * @param comment
     * @return
     */
    public boolean addComment(Comment comment);

    /**
     * 展示留言
     * @param bookid
     * @return
     */
    public List<Comment> selectComment(Integer bookid);
}

RecordDao

package com.sjsq.dao;

import com.sjsq.po.Record;

import java.util.List;

/**
 * @author shuijianshiqing
 * @date 2021/5/22 22:07
 */
public interface RecordDao {

    /**
     * 查询所有借阅信息
     * @return
     */
    public List<Record> selectRecords();

    /**
     * 查询借阅信息
     * @return
     */
    public List<Record> selectRecord(Integer userid);


    /**
     * 新增借阅记录
     * @param record
     * @return
     */
    public boolean addRecord(Record record);


    /**
     * 删除借阅记录
     * @param borrowid
     * @return
     */
    public boolean deleteRecord(Integer borrowid);
}

UserDao

package com.sjsq.dao;

import com.sjsq.po.User;

import java.util.List;

/**
 * @author shuijianshiqing
 * @date 2020/5/20 22:10
 * 创建一个接口用于声明用户登录注册的方法
 */

public interface UserDao {

    /**
     * 用户登录
     * @param user
     * @return
     */
    public User login(User user);

    /**
     * 用户注册
     * @param user
     * @return
     */
    public boolean register(User user);

    /**
     * 查询用户信息
     * @param sql
     * @param arr
     * @return
     */
    public List<User> selectUser(String sql, Object arr[]);



    /**
     * 根据用户编号进行查询
     * @param userid
     * @return
     */
    public User getUser(Integer userid);


    /**
     * 新增用户
     * @param user
     * @return
     */
    public boolean addUser(User user);

    /**
     * 修改用户
     * @param user
     * @return
     */
    public boolean updateUser(User user);

    /**
     * 删除用户
     * @param userid
     * @return
     */
    public boolean deleteUser(Integer userid);
}

BookService

package com.sjsq.service;

import com.sjsq.po.Book;

import java.util.List;

/**
 * @author shuijianshiqing
 * @date 2020/5/20 23:37
 * Book的Service层
 */
public interface BookService {

    /**
     * 查询图书信息
     * @param bookname
     * @return
     */
    public List<Book> select(String bookname);

    /**
     * 根据图书编号进行查询
     * @param id
     * @return
     */
    public Book getBook(Integer id);


    /**
     * 图书新增
     * @param book
     * @return
     */
    public boolean addBook(Book book);

    /**
     * 图书修改
     * @param book
     * @return
     */
    public boolean updateBook(Book book);

    /**
     * 删除图书
     * @param bookid
     * @return
     */
    public boolean deleteBook(Integer bookid);
}

BookShelfService

package com.sjsq.service;

import com.sjsq.po.BookShelf;

import java.util.List;

/**
 * @author shuijianshiqing
 * @date 2021/5/22 12:36
 */
public interface BookShelfService {

    /**
     * 按照用户名检索书架
     * @param userid
     * @return
     */
    public List<BookShelf> selectBookShelf(Integer userid);

    /**
     * 加入书架
     * @param bookShelf
     * @return
     */
    public boolean addBookShelf(BookShelf bookShelf);


    /**
     * 移出书架
     * @param userid
     * @param bookid
     * @return
     */
    public boolean removeBookShelf(Integer userid,Integer bookid);

}

CommentService

package com.sjsq.service;

import com.sjsq.po.Comment;

import java.util.List;

/**
 * @author shuijianshiqing
 * @date 2021/5/22 17:21
 */
public interface CommentService {
    /**
     * 添加留言
     * @param comment
     * @return
     */
    public boolean addComment(Comment comment);

    /**
     * 展示留言
     * @param bookid
     * @return
     */
    public List<Comment> selectComment(Integer bookid);

}

RecordService

package com.sjsq.service;

import com.sjsq.po.Record;

import java.util.List;

/**
 * @author shuijianshiqing
 * @date 2021/5/22 22:17
 */
public interface RecordService {

    /**
     * 查询所有借阅信息
     * @return
     */
    public List<Record> selectRecords();

    /**
     * 查询借阅信息
     * @return
     */
    public List<Record> selectRecord(Integer userid);


    /**
     * 新增借阅记录
     * @param record
     * @return
     */
    public boolean addRecord(Record record);


    /**
     * 删除借阅记录
     * @param borrowid
     * @return
     */
    public boolean deleteRecord(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 + "/";
    %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户登录</title>
    <style type="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>
    <form action="login-do-info.jsp" method="post">
        <h1>用户登录</h1>
        <hr/>
        <table align="center">
            <tr>
                <td>账号:</td>
                <td><input type="text" name="username" id="username" placeholder="请输入您的账号" autofocus="autofocus"></td>
            </tr>
            <tr>
                <td>密码:</td>
                <td><input type="password" name="password" id="password" placeholder="请输入您的密码"></td>
                <td><a href="search-password.jsp">找回密码</a></td>
            </tr>
            <tr>
                <td colspan="1">
                </td>
                <td>
                    <input type="submit" value="登录"/>
                    <input type="reset" value="重置"/>
                    <a href="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 + "/";
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
    <base href="<%=basePath %>"/>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户登录</title>
    <style type="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>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>登录失败</title>
    <style type="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>
        <a href="login.jsp">返回登录</a>
    </div>
</body>
</html>

logout.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<html>
<head>
    <meta http-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" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>用户注册</title>
    <style type="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/>
    <form action="register-do.jsp" method="post" name="registerForm">
        <div>
            <tr>
                <label>您的账号:</label>
                <input type="text" name="name" id="name" placeholder="请输入用户名">
            </tr>
        </div>
        <div>
            <tr>
                <label>您的密码:</label>
                <input type="password" name="password" id="password" placeholder="请输入密码">
            </tr>
        </div>
        <div>
            <tr>
                <label>确认密码:</label>
                <input type="password" name="relpassword" id="relpassword" placeholder="请确认密码">
            </tr>
        </div>
        <div>
            <tr>
                <label>电话号码:</label>
                <input type="text" name="phone" id="phone" placeholder="请输入电话号码">
            </tr>
        </div>
        <div>
            <tr>
                <label>电子邮件:</label>
                <input type="text" name="email" id="email" placeholder="请输入电子邮件">
            </tr>

        </div>
        <div>
            <tr>
                <button type="submit" onclick="return checkForm()">注册</button>
                <button type="reset">重置</button>
                <a href="login.jsp" target="_blank">登录</a>
            </tr>
        </div>
    </form>

    <script type="text/javascript">
        function checkForm() {
            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();
                return false;
            } else if (pwd == "" || pwd == null) {
                alert("请输入密码");
                registerForm.password.focus();
                return false;
            } else if (repwd == "" || repwd == null) {
                alert("请输入确认密码");
                registerForm.relpassword.focus();
                return false;
            } else if (pwd != repwd) {
                alert("两次密码输入不一致,请重新输入!");
                registerForm.relpassword.focus();
                return false;
            }
            alert('注册成功!');
            return true;
        }
    </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"%>
<!DOCTYPE html>
<html>
<head>
    <meta http-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 + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>找回密码</title>
    <style type="text/css">
        h1{
            text-align: center;
        }
        div{
            text-align: center;
        }
        body{
            background-color:antiquewhite;
        }
    </style>
</head>
<body>
    <h1>找回密码</h1>
    <hr>
    <div>
        <a href="javascript: window.history.go(-1)">返回上一级</a>
    </div>
    <br>
    <form action="search-password-do.jsp" method="post">
        <table align="center">
            <tr>
                <td>请输入账号:</td>
                <td><input type="text" name="name"/></td>
            </tr>
            <tr>
                <td colspan="1"></td>
                <td>
                    <input type="submit" value="提交">
                    <input type="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 + "/";
    %>
<!DOCTYPE html>
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-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 + "/";
%>
<!DOCTYPE html>
<html>
<head>
    <base href="<%=basePath %>" />
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>弹出信息</title>
    <script type="text/javascript">
        alert("您的密码是:${user.password}");
    </script>
    <style type="text/css">
        h1{
            text-align: center;
        }
        div{
            text-align: center;
        }
    </style>
</head>
<body>
    <h1>您的密码是:${user.password}</h1>

    <div>
        <td><a href="login.jsp">返回登录</a></td>
    </div>
</body>
</html>

admin-home.jsp

<%@ page contentType="text/html;charset=UTF-8" language="java" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>管理员主页</title>
    <style type="text/css">

        body {
            background-color: antiquewhite;
            text-align: center;
        }

    </style>
</head>
<body>
<%-- 头部 --%>
<jsp:include page="top.jsp"/>
<h1>欢迎来到图书管理系统</h1>

<hr>
<h4>管理员操作</h4>

    <a href="admin-user-manager.jsp">管理用户</a>
    <a href="admin-book-manager.jsp">管理图书</a>
</body>
</html>

admin-book-add.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>新增图书</title>
    <style type="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:include page="top.jsp"/>

<h1>新增图书</h1>
<hr>

<div id="before">
    <a href="javascript: window.history.go(-1)">返回上一级</a>
</div>
</br>

<form action="admin-book-do-add.jsp" method="post" name="registerForm">
    <div>
        <tr>
            <label>图书名称:</label>
            <input type="text" name="bookname" id="bookname" placeholder="图书名称" autofocus="autofocus">
        </tr>
    </div>
    <div>
        <tr>
            <label>图书价格:</label></td>
            <input type="text" name="price" id="price" placeholder="图书价格(数字)">
        </tr>
    </div>
    <div>
        <tr>
            <label>图书作者:</label>
            <input type="text" name="author" id="author" placeholder="图书作者">
        </tr>
    </div>
    <div>
        <tr>
            <label>出版公司:</label>
            <input type="text" name="publish" id="publish" placeholder="出版公司">
        </tr>
    </div>
    <div>
        <tr>
            <label>类型编号:</label>
            <input type="text" name="categoryid" id="categoryid" placeholder="类型编号">
        </tr>
    </div>
    <div>
        <tr>
            <label>书籍链接:</label>
            <input type="text" name="booklink" id="booklink" placeholder="书籍链接">
        </tr>
    </div>

    <div id="submitbtn">
        <tr>
            <button type="submit" onclick="return checkForm()">添加</button>
            <button type="reset">重置</button>

        </tr>
    </div>
</form>

<script type="text/javascript">
    function checkForm() {
        var bookname = registerForm.bookname.value;
        var price = registerForm.price.value;
        if (bookname == "" || bookname == null) {
            alert("请输入图书名称");
            registerForm.bookname.focus();
            return false;
        } else if (price == "" || price == null) {
            alert("请输入图书价格");
            registerForm.price.focus();
            return false;
        }
        alert('添加成功!');
        return true;
    }
</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>
    <style type="text/css">
        #before {
            text-align: center;
        }

        body {
            background-color: antiquewhite;
        }


    </style>
</head>
<body>

<%-- 头部 --%>
<jsp:include page="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" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>修改图书</title>
    <style type="text/css">
        h1 {
            text-align: center;
        }

        h4 {
            text-align: center;
            color: red;
        }

        body {
            background-color: antiquewhite;
        }

        div {
            text-align: center;
        }

    </style>
</head>
<body>

<%-- 头部 --%>
<jsp:include page="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);
%>
<form action="admin-book-do-update.jsp" method="post" name="registerForm">
    <div>
        <tr>
            <input type="hidden" name="bookid" id="bookid" value="<%=book.getBookid()%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>图书名称:</label>
            <input type="text" name="bookname" id="bookname" value="<%=book.getBookname()%>" autofocus="autofocus">
        </tr>
    </div>
    <div>
        <tr>
            <label>图书价格:</label></td>
            <input type="text" name="price" id="price" value="<%=book.getPrice()%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>图书作者:</label>
            <input type="text" name="author" id="author" value="<%=book.getAuthor()%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>出版公司:</label>
            <input type="text" name="publish" id="publish" value="<%=book.getPublish()%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>类型编号:</label>
            <input type="text" name="categoryid" id="categoryid" value="<%=book.getCategoryid()%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>书籍链接:</label>
            <input type="text" name="booklink" id="booklink" value="<%=book.getBooklink()%>">
        </tr>
    </div>

    <div>
        <tr>
            <button type="submit" onclick="return checkForm()">修改</button>
            <button type="reset">重置</button>
        </tr>
    </div>
</form>

<script type="text/javascript">
    function checkForm() {
        var bookname = registerForm.bookname.value;
        var price = registerForm.price.value;
        //alert(name + pwd + repwd);
        if (bookname == "" || bookname == null) {
            alert("请输入图书名称");
            registerForm.bookname.focus();
            return false;
        } else if (price == "" || price == null) {
            alert("请输入图书价格");
            registerForm.price.focus();
            return false;
        }
        alert('修改成功!');
        return true;
    }
</script>
</body>
</html>

admin-user-add.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>新增用户</title>
    <style type="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:include page="top.jsp"/>

<h1>新增用户</h1>
<hr>

<div id="before">
    <a href="javascript: window.history.go(-1)">返回上一级</a>
</div>
</br>

<form action="admin-user-do-add.jsp" method="post" name="registerForm">
    <div>
        <tr>
            <label>账号:</label>
            <input type="text" name="username" id="username" placeholder="用户名" autofocus="autofocus">
        </tr>
    </div>
    <div>
        <tr>
            <label>密码:</label></td>
            <input type="text" name="password" id="password" placeholder="密码">
        </tr>
    </div>
    <div>
        <tr>
            <label>邮箱:</label>
            <input type="text" name="email" id="email" placeholder="邮箱">
        </tr>
    </div>
    <div>
        <tr>
            <label>电话:</label>
            <input type="text" name="phone" id="phone" placeholder="电话">
        </tr>
    </div>
    <div>
        <tr>
            <label>是否管理员:</label>
            <input type="text" name="isadmin" id="isadmin" placeholder="是否管理员(1是,0否)">
        </tr>
    </div>

    <div id="submitbtn">
        <tr>
            <button type="submit" onclick="return checkForm()">添加</button>
            <button type="reset">重置</button>

        </tr>
    </div>
</form>

<script type="text/javascript">
    function checkForm() {
        var username = registerForm.username.value;
        var password = registerForm.password.value;
        if (username == "" || username == null) {
            alert("请输入用户名");
            registerForm.username.focus();
            return false;
        } else if (password == "" || password == null) {
            alert("请输入密码");
            registerForm.password.focus();
            return false;
        }
        alert('添加成功!');
        return true;
    }
</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>
    <style type="text/css">
        #before {
            text-align: center;
        }

        body {
            background-color: antiquewhite;
        }


    </style>
</head>
<body>

<%-- 头部 --%>
<jsp:include page="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" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>修改用户</title>
    <style type="text/css">
        h1 {
            text-align: center;
        }

        h4 {
            text-align: center;
            color: red;
        }

        body {
            background-color: antiquewhite;
        }

        div {
            text-align: center;
        }

    </style>
</head>
<body>

<%-- 头部 --%>
<jsp:include page="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);
%>
<form action="admin-user-do-update.jsp" method="post" name="registerForm">
    <div>
        <tr>
            <label>编号:</label>
            <input type="text" name="userid" id="userid" readonly="readonly" value="<%=user.getUserid()%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>用户:</label>
            <input type="text" name="username" id="username" readonly="readonly" value="<%=user.getUsername()%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>密码:</label>
            <input type="text" name="password" id="password" value="<%=user.getPassword()%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>邮箱:</label>
            <input type="text" name="email" id="email" value="<%=user.getEmail()%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>电话:</label>
            <input type="text" name="phone" id="phone" value="<%=user.getPhone()%>">
        </tr>
    </div>
    <div>
        <tr>
            <label>是否管理员:</label>
            <input type="text" name="isadmin" id="isadmin" value="<%=user.getIsadmin()%>">
        </tr>
    </div>



    <div>
        <tr>
            <button type="submit" onclick="return checkForm()">修改</button>
            <button type="reset">重置</button>
        </tr>
    </div>
</form>

<script type="text/javascript">
    function checkForm() {
        var password = registerForm.password.value;
        if (password == "" || password == null) {
            alert("请输入密码");
            registerForm.password.focus();
            return false;
        }
        alert('修改成功!');
        return true;
    }
</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" %>
<!DOCTYPE html>
<html>
<head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
    <title>查看图书</title>
    <style type="text/css">
        h1 {
            text-align: center;
        }

        #before {
            text-align: center;
        }

    </style>
</head>
<body>

<%-- 头部 --%>
<jsp:include page="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>
<div id="before">
    <form action="user-home.jsp" method="post">
        请输入书名:<input type="text" name="bookname" placeholder="输入图书名称搜索">
        <input type="submit" value="查询"/>
    </form>
    <a href="javascript: window.history.go(-1)">返回上一级</a>
</div>
<br>
<table align="center" cellspacing="0">
    <tr bgcolor="#5f9ea0" style="font-size: 20px;height:40px;text-align: center">
        <td style="width: 120px">编号</td>
        <td style="width: 120px">书名</td>
        <td style="width: 120px">价格</td>
        <td style="width: 120px">作者</td>
        <td style="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";
            }

    %>
    <tr bgcolor="<%=bg%>" style="height:40px;text-align: center">
        <td><%=b.getBookid()%>
        </td>
        <td><a href="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>
    <style type="text/css">

        body {
            background-color: antiquewhite;
        }


    </style>
</head>
<body>

<%-- 头部 --%>
<jsp:include page="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资源。如果此文对您有帮助,请关注加点赞,谢谢!

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值