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

本文涉及的产品
云数据库 RDS MySQL,集群系列 2核4GB
推荐场景:
搭建个人博客
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介: IDEA+Java+SSM+JSP+Mysql实现Web图书管理系统

一、系统介绍


1.开发环境


开发工具:IDEA2018


JDK版本:jdk1.8


Mysql版本:8.0.13


2.技术选型


Java+Spring+SpringMVC+Mybatis+Jsp+Mysql


3.系统功能


1.用户登录退出系统


2.用户借阅查看书籍


3.管理员登录退出系统


4.管理员对书籍的增删改查


5.管理员对书籍类型的增删改查


6.管理员对用户的增删改查


7.管理员对用户类型的增删改查


8.管理员查看借阅记录


4.数据库文件

/*
 Navicat Premium Data Transfer
 Source Server         : MYSQL
 Source Server Type    : MySQL
 Source Server Version : 80013
 Source Host           : localhost:3306
 Source Schema         : ssm_library_management
 Target Server Type    : MySQL
 Target Server Version : 80013
 File Encoding         : 65001
 Date: 12/12/2021 16:30:13
*/
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;
-- ----------------------------
-- Table structure for admin
-- ----------------------------
DROP TABLE IF EXISTS `admin`;
CREATE TABLE `admin`  (
  `id` bigint(4) NOT NULL AUTO_INCREMENT,
  `username` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `password` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 2 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of admin
-- ----------------------------
INSERT INTO `admin` VALUES (1, 'admin', 'admin');
-- ----------------------------
-- Table structure for book
-- ----------------------------
DROP TABLE IF EXISTS `book`;
CREATE TABLE `book`  (
  `id` bigint(4) NOT NULL AUTO_INCREMENT,
  `type` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `name` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `number` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `author` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `press` varchar(20) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `publicationdate` date NULL DEFAULT NULL,
  `price` decimal(10, 2) NULL DEFAULT NULL,
  `pagecount` int(4) NULL DEFAULT NULL,
  `keyword` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `createtime` date NULL DEFAULT NULL,
  `isborrow` int(4) NULL DEFAULT NULL,
  `remark` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `BOOK_PK`(`type`) USING BTREE,
  CONSTRAINT `BOOK_PK` FOREIGN KEY (`type`) REFERENCES `booktype` (`number`) ON DELETE CASCADE ON UPDATE CASCADE
) ENGINE = InnoDB AUTO_INCREMENT = 27 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of book
-- ----------------------------
INSERT INTO `book` VALUES (14, 'bt004', '大雪中的山庄', 'b001', '东野圭吾 ', '北京十月文艺出版社', '2018-06-16', 36.00, 200, NULL, NULL, 0, '1');
INSERT INTO `book` VALUES (16, 'bt004', '特工皇妃', 'b004', '潇湘冬儿', '江苏文艺出版社', '2011-05-05', 74.80, 333, NULL, NULL, 0, NULL);
INSERT INTO `book` VALUES (17, 'bt006', '人类简史', 'b005', '[以色列] 尤瓦尔·赫拉利 ', '中信出版社', '2014-11-01', 68.00, 100, NULL, NULL, 0, NULL);
INSERT INTO `book` VALUES (18, 'bt006', '明朝那些事儿(1-9)', 'b006', '当年明月 ', '中国海关出版社', '2009-04-06', 358.20, 500, NULL, NULL, 0, NULL);
INSERT INTO `book` VALUES (19, 'bt002', '经济学原理(上下)', 'b007', '[美] 曼昆 ', '机械工业出版社', '2003-08-05', 88.00, 156, NULL, NULL, 0, NULL);
INSERT INTO `book` VALUES (20, 'bt004', '方向', 'b008', '马克-安托万·马修 ', '北京联合出版公司', '2017-04-01', 99.80, 186, NULL, NULL, 0, NULL);
INSERT INTO `book` VALUES (21, 'bt004', '画的秘密', 'b009', '马克-安托万·马修 ', '北京联合出版公司', '2016-01-01', 60.00, 556, NULL, NULL, 0, NULL);
INSERT INTO `book` VALUES (22, 'bt004', '造彩虹的人', 'b010', '东野圭吾 ', '北京十月文艺出版社', '2017-06-01', 39.50, 775, NULL, NULL, 0, NULL);
INSERT INTO `book` VALUES (23, 'bt004', '控方证人', 'b011', '阿加莎·克里斯蒂 ', '新星出版社', '2017-05-01', 35.00, 195, NULL, NULL, 0, NULL);
INSERT INTO `book` VALUES (24, 'bt004', '少有人走的路', 'b012', 'M·斯科特·派克 ', '吉林文史出版社', '2007-01-01', 26.00, 300, NULL, NULL, 0, NULL);
INSERT INTO `book` VALUES (25, 'bt004', '追寻生命的意义', 'b013', '[奥] 维克多·弗兰克 ', '新华出版社', '2003-01-01', 12.00, 250, NULL, NULL, 0, NULL);
INSERT INTO `book` VALUES (26, 'bt004', '秘密花园', 'b014', '乔汉娜·贝斯福 ', '北京联合出版公司', '2015-06-01', 42.00, 450, NULL, NULL, 0, NULL);
-- ----------------------------
-- Table structure for booktype
-- ----------------------------
DROP TABLE IF EXISTS `booktype`;
CREATE TABLE `booktype`  (
  `id` bigint(4) NOT NULL AUTO_INCREMENT,
  `number` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `name` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `keyword` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `remark` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `createtime` date NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `number`(`number`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 23 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of booktype
-- ----------------------------
INSERT INTO `booktype` VALUES (5, 'bt001', '军事', NULL, NULL, NULL);
INSERT INTO `booktype` VALUES (6, 'bt002', '经济', NULL, NULL, NULL);
INSERT INTO `booktype` VALUES (8, 'bt003', '语言', NULL, NULL, NULL);
INSERT INTO `booktype` VALUES (9, 'bt004', '文学', NULL, NULL, NULL);
INSERT INTO `booktype` VALUES (10, 'bt005', '艺术', NULL, NULL, NULL);
INSERT INTO `booktype` VALUES (11, 'bt006', '历史', NULL, NULL, NULL);
INSERT INTO `booktype` VALUES (22, 'bt007', '综合', NULL, NULL, NULL);
INSERT INTO `booktype` VALUES (23, 'bt008', '地理', NULL, NULL, NULL);
-- ----------------------------
-- Table structure for reader
-- ----------------------------
DROP TABLE IF EXISTS `reader`;
CREATE TABLE `reader`  (
  `id` bigint(4) NOT NULL AUTO_INCREMENT,
  `number` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `name` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `type` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `sex` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `workunit` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `homeaddress` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `tel` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `email` varchar(30) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `createtime` date NULL DEFAULT NULL,
  `remark` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of reader
-- ----------------------------
INSERT INTO `reader` VALUES (1, 'r001', '张三', 'rt002', '女', '广州', '广州', '15626277129', '913772015@qq.com', NULL, NULL);
INSERT INTO `reader` VALUES (2, 'r002', '李四', 'rt001', '男', NULL, NULL, NULL, NULL, NULL, NULL);
INSERT INTO `reader` VALUES (5, 'r003', '王五', 'rt001', '男', '市委', '湖南长沙', '12345678911', 'wangwu@qq.com', '2021-12-11', NULL);
-- ----------------------------
-- Table structure for reader_account
-- ----------------------------
DROP TABLE IF EXISTS `reader_account`;
CREATE TABLE `reader_account`  (
  `id` bigint(4) NOT NULL,
  `username` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `password` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of reader_account
-- ----------------------------
INSERT INTO `reader_account` VALUES (1, 'r001', 'r001');
INSERT INTO `reader_account` VALUES (2, 'r002', 'r002');
INSERT INTO `reader_account` VALUES (3, 'r003', 'r003');
-- ----------------------------
-- Table structure for readertype
-- ----------------------------
DROP TABLE IF EXISTS `readertype`;
CREATE TABLE `readertype`  (
  `id` bigint(4) NOT NULL AUTO_INCREMENT,
  `number` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `name` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `borrownumber` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '借书数量',
  `borrowterm` varchar(10) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL COMMENT '借书期限',
  `remark` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `createtime` date NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 3 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of readertype
-- ----------------------------
INSERT INTO `readertype` VALUES (1, 'rt001', '一级读者', '8', '30', NULL, NULL);
INSERT INTO `readertype` VALUES (2, 'rt002', '二级读者', '10', '60', NULL, NULL);
-- ----------------------------
-- Table structure for record
-- ----------------------------
DROP TABLE IF EXISTS `record`;
CREATE TABLE `record`  (
  `id` bigint(4) NOT NULL AUTO_INCREMENT,
  `readernumber` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `booknumber` varchar(8) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  `borrowdate` date NULL DEFAULT NULL,
  `returndate` date NULL DEFAULT NULL,
  `remark` varchar(50) CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  INDEX `reader`(`readernumber`) USING BTREE,
  INDEX `book`(`booknumber`) USING BTREE
) ENGINE = InnoDB AUTO_INCREMENT = 11 CHARACTER SET = utf8 COLLATE = utf8_general_ci ROW_FORMAT = Dynamic;
-- ----------------------------
-- Records of record
-- ----------------------------
INSERT INTO `record` VALUES (8, 'r002', 'b001', '2018-06-27', '2018-06-27', NULL);
INSERT INTO `record` VALUES (9, 'r001', 'b001', '2018-06-27', '2018-06-27', NULL);
INSERT INTO `record` VALUES (10, 'r001', 'b001', '2018-06-27', '2018-06-27', NULL);
INSERT INTO `record` VALUES (11, 'r001', 'b001', '2021-12-11', '2021-12-11', '');
INSERT INTO `record` VALUES (12, 'r001', 'b001', '2021-12-11', '2021-12-11', NULL);
INSERT INTO `record` VALUES (14, 'r001', 'b001', '2021-12-11', '2021-12-11', 'r001');
INSERT INTO `record` VALUES (15, 'r001', 'b004', '2021-12-11', '2021-12-11', 'r001');
INSERT INTO `record` VALUES (16, 'r001', 'b005', '2021-12-11', '2021-12-11', 'r001');
SET FOREIGN_KEY_CHECKS = 1;


二、系统展示


1.登录系统


image.jpeg


2.用户-借阅书籍


image.jpeg


3.管理员-图书管理


8941cadd79b740ca9e0bd67f3081aabd.jpg


4.管理员-图书类型管理


087aa040dbd341958a1f45cbf5706e0a.jpg


5.管理员-读者管理


99f5dc6b1f8741a9970bf677a268fba1.jpg


6.管理员-读者类型管理


a958f297e8254f50aa1be6ebaad5147f.jpg


7.管理员-借阅记录查看


da0a2608ed3f414eb831f034e10695df.jpg


三、部分代码


BookController

package com.sjsq.controller;
import com.sjsq.pojo.Book;
import com.sjsq.pojo.BookType;
import com.sjsq.pojo.Record;
import com.sjsq.service.BookService;
import com.sjsq.service.ReaderService;
import com.sjsq.service.RecordService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Controller
public class BookController {
    @Autowired
    private BookService bookService;
    @Autowired
    private RecordService recordService;
    @Autowired
    private ReaderService readerService;
    @RequestMapping("/book/list")
    public String bookList(Model model, HttpServletRequest request) throws Exception {
        request.setCharacterEncoding("UTF-8");
        String name = request.getParameter("bookName");
        String type = request.getParameter("bookType");
        String press = request.getParameter("bookPress");
        List<Book> bookList = bookService.queryBook(name, type, press);
        List<BookType> bookTypeList = bookService.queryAllBookType();
        List<String> bookNumberList = bookService.queryBookNumber();
        List<String> readerNumberList = readerService.queryReaderNumber();
        model.addAttribute("books", bookList);
        request.getSession().setAttribute("bookTypes", bookTypeList);
        request.getSession().setAttribute("bookNumbers", bookNumberList);
        request.getSession().setAttribute("readerNumbers", readerNumberList);
        model.addAttribute("bookName", name);
        model.addAttribute("bookType", type);
        return "admin_books";
    }
    @RequestMapping("/book/listreader")
    public String bookListReader(Model model, HttpServletRequest request) throws Exception {
        request.setCharacterEncoding("UTF-8");
        String name = request.getParameter("bookName");
        String type = request.getParameter("bookType");
        String press = request.getParameter("bookPress");
        List<Book> bookList = bookService.queryBook(name, type, press);
        List<BookType> bookTypeList = bookService.queryAllBookType();
        List<String> bookNumberList = bookService.queryBookNumber();
        List<String> readerNumberList = readerService.queryReaderNumber();
        model.addAttribute("books", bookList);
        request.getSession().setAttribute("bookTypes", bookTypeList);
        request.getSession().setAttribute("bookNumbers", bookNumberList);
        request.getSession().setAttribute("readerNumbers", readerNumberList);
        model.addAttribute("bookName", name);
        model.addAttribute("bookType", type);
        return "reader_books";
    }
    @RequestMapping("/book/edit.action")
    public @ResponseBody
    Book bookEdit(String number) {
        Book book = bookService.queryBookByNumber(number);
        return book;
    }
    @RequestMapping("/book/update.action")
    public @ResponseBody
    String bookUpdate(Book book) {
        bookService.updateBookById(book);
        return "OK";
    }
    /*用book实体接收不了前端传过来的变量,只能一个一个收*/
    @RequestMapping("/book/add.action")
    public @ResponseBody
    String bookAdd(HttpServletRequest request) throws Exception {
        Date publicationdate = null;
        Integer pagecount = null;
        BigDecimal price = null;
        String name = request.getParameter("name");
        String type = request.getParameter("type");
        String author = request.getParameter("anthor");
        String number = request.getParameter("number");
        String press = request.getParameter("press");
        String publicationdateStr = request.getParameter("publicationdate");
        String priceStr = request.getParameter("price");
        String pagecountStr = request.getParameter("pagecount");
        String remark = request.getParameter("remark");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String createtimeStr = sdf.format(new Date());
        Date createtime = sdf.parse(createtimeStr);
        if (publicationdateStr != "") {
            publicationdate = sdf.parse(publicationdateStr);
        }
        if (pagecountStr != "") {
            pagecount = Integer.parseInt(pagecountStr);
        }
        if (priceStr != "") {
            price = new BigDecimal(priceStr);
        }
        Book book = new Book(type, name, number, author, press, publicationdate,
                price, pagecount, createtime, 0, remark);
        bookService.addBook(book);
        return "OK";
    }
    @RequestMapping("/book/delete.action")
    public @ResponseBody
    String bookDelete(String number) {
        bookService.deleteBookByNumber(number);
        return "OK";
    }
    @RequestMapping("/book/lent.action")
    public @ResponseBody
    String lentBook(HttpServletRequest request) throws Exception {
        String bookNumber = request.getParameter("bookNumber");
        String readerNumber = request.getParameter("readerNumber");
        String remark = request.getParameter("remark");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String borrowtimeStr = sdf.format(new Date());
        Date borrowtime = sdf.parse(borrowtimeStr);
        Record record = new Record();
        record.setReaderNumber(readerNumber);
        record.setBookNumber(bookNumber);
        record.setBorrowDate(borrowtime);
        record.setRemark(remark);
        bookService.updateBookStatusByNumber(1, bookNumber);
        recordService.addRecord(record);
        return "OK";
    }
    @RequestMapping("/book/return.action")
    public @ResponseBody
    String returnBook(HttpServletRequest request) throws Exception {
        String bookNumber = request.getParameter("bookNumber");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String returntimeStr = sdf.format(new Date());
        Date returntime = sdf.parse(returntimeStr);
        bookService.updateBookStatusByNumber(0, bookNumber);
        recordService.setReturnDate(bookNumber, returntime);
        return "OK";
    }
    @RequestMapping("/record/list")
    public String recordList(Model model, HttpServletRequest request) throws Exception {
        request.setCharacterEncoding("UTF-8");
        List<Record> recordList = recordService.queryAllFullRecord();
        model.addAttribute("records", recordList);
        return "record";
    }
}

BookTypeController

package com.sjsq.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sjsq.pojo.BookType;
import com.sjsq.service.BookService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Controller
public class BookTypeController {
    @Autowired
    private BookService bookService;
    @RequestMapping("/booktype/list")
    public String bookTypeList(Model model, HttpServletRequest request) throws Exception {
        request.setCharacterEncoding("UTF-8");
        List<BookType> bookTypeList = bookService.queryAllBookType();
        ObjectMapper om = new ObjectMapper();
        String jsonStr = om.writeValueAsString(bookTypeList);
        System.out.println(jsonStr);
        model.addAttribute("bookTypes", bookTypeList);  //前端foreach标签好像解析不了json
        model.addAttribute("bookTypesJSON", jsonStr);
        return "admin_booktype";
    }
    @RequestMapping("/booktype/edit.action")
    public @ResponseBody
    BookType bookTypeEdit(String number) {
        BookType booktype = bookService.queryBookTypeByNumber(number);
        return booktype;
    }
    @RequestMapping("/booktype/update.action")
    public @ResponseBody
    String bookTypeUpdate(BookType bookType) {
        bookService.updateBookTypeById(bookType);
        return "OK";
    }
    @RequestMapping("/booktype/add.action")
    public @ResponseBody
    String bookTypeAdd(HttpServletRequest request) throws Exception {
    /*private int id;
    private String number;
    private String name;
    private String keyword;
    private String remark;*/
        String name = request.getParameter("name");
        String number = request.getParameter("number");
        String remark = request.getParameter("remark");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String createtimeStr = sdf.format(new Date());
        Date createtime = sdf.parse(createtimeStr);
        BookType bookType = new BookType(number, name, remark, createtime);
        bookService.addBookType(bookType);
        return "OK";
    }
    @RequestMapping("/booktype/delete.action")
    public @ResponseBody
    String bookTypeDelete(String number) {
        bookService.deleteBookTypeByNumber(number);
        return "OK";
    }
}

LoginController

package com.sjsq.controller;
import com.sjsq.pojo.Admin;
import com.sjsq.pojo.ReaderAccount;
import com.sjsq.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;
@Controller
public class LoginController {
    @Autowired
    private LoginService loginService;
    @RequestMapping(value = {"/", "/login.html"})
    public String toLogin(HttpServletRequest request) {
        return "index";
    }
    @RequestMapping("/logout.html")
    public String logout(HttpServletRequest request) {
        return "redirect:/login.html";
    }
    @RequestMapping("/logincheck")
    public @ResponseBody
    Object loginCheck(HttpServletRequest request) {
        HashMap<String, String> res = new HashMap<String, String>();
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        Admin admin = loginService.queryAdminByUsernameAndPasswd(username, password);
        ReaderAccount readerAccount = loginService.queryReaderAccountByUsernameAndPasswd(username, password);
        if (admin != null && readerAccount == null) {
            res.put("stateCode", "1");
            request.getSession().setAttribute("admin", admin);
        } else if (admin == null && readerAccount != null) {
            res.put("stateCode", "2");
            request.getSession().setAttribute("readerAccount", readerAccount);
        } else {
            res.put("stateCode", "0");
        }
        return res;
    }
    @RequestMapping("/admin_main.html")
    public String toAdminMain(HttpServletResponse response) {
        return "admin_main";
    }
    @RequestMapping("/reader_main.html")
    public String toReaderMain(HttpServletResponse response) {
        return "reader_main";
    }
}

ReaderTypeController

package com.sjsq.controller;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.sjsq.pojo.ReaderType;
import com.sjsq.service.ReaderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletRequest;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@Controller
public class ReaderTypeController {
    @Autowired
    private ReaderService readerService;
    @RequestMapping("/readertype/list")
    public String readerTypeList(Model model, HttpServletRequest request) throws Exception {
        request.setCharacterEncoding("UTF-8");
        List<ReaderType> readerTypeList = readerService.queryAllReaderType();
        ObjectMapper om = new ObjectMapper();
        String jsonStr = om.writeValueAsString(readerTypeList);
        System.out.println(jsonStr);
        model.addAttribute("readerTypes", readerTypeList);  //前端foreach标签好像解析不了json
        model.addAttribute("readerTypesJSON", jsonStr);
        return "admin_readertype";
    }
    @RequestMapping("/readertype/edit.action")
    public @ResponseBody
    ReaderType readerTypeEdit(String number) {
        ReaderType readertype = readerService.queryReaderTypeByNumber(number);
        return readertype;
    }
    @RequestMapping("/readertype/update.action")
    public @ResponseBody
    String readerTypeUpdate(ReaderType readerType) {
        readerService.updateReaderTypeById(readerType);
        return "OK";
    }
    @RequestMapping("/readertype/add.action")
    public @ResponseBody
    String readerTypeAdd(HttpServletRequest request) throws Exception {
        String name = request.getParameter("name");
        String number = request.getParameter("number");
        String borrownumber = request.getParameter("borrownumber");
        String borrowterm = request.getParameter("borrowterm");
        String remark = request.getParameter("remark");
        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
        String createtimeStr = sdf.format(new Date());
        Date createtime = sdf.parse(createtimeStr);
        ReaderType readerType = new ReaderType(number, name, borrownumber, borrowterm, remark, createtime);
        readerService.addReaderType(readerType);
        return "OK";
    }
    @RequestMapping("/readertype/delete.action")
    public @ResponseBody
    String readerTypeDelete(String number) {
        readerService.deleteReaderTypeByNumber(number);
        return "OK";
    }
}


四、其他


1.更多系统


Java+JSP系统系列实现


Java+JSP实现学生图书管理系统


Java+JSP实现学生信息管理系统


Java+JSP实现用户信息管理系统


Java+Servlet系统系列实现


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+JSP实现超市管理系统


Java+SSM+JSP实现学生成绩管理系统


Java+SSM+JSP实现学生信息管理系统


Java+SSM+JSP+Maven实现网上书城系统


Java+SSM+JSP+Maven实现学校教务管理系统


Java+SSH系统系列实现

Java+SSH+JSP实现在线考试系统


Java+SSH+JSP实现医院在线挂号系统


Java+Springboot系统系列实现

Java+Springboot+H-ui+Maven实现营销管理系统


Java+Springboot+Bootstrap+Maven实现网上商城系统


Java+Springboot+Bootstrap+Maven实现景区旅游管理系统


1.更多JavaWeb系统请关注专栏。


https://blog.csdn.net/helongqiang/category_10020130.html

https://blog.csdn.net/helongqiang/category_10020130.html


2.更多JavaSwing系统请关注专栏。


https://blog.csdn.net/helongqiang/category_6229101.html

https://blog.csdn.net/helongqiang/category_6229101.html


2.源码下载

sql在sql文件夹下面


Java+SSM+Bootstrap+Jsp+Mysql实现Web图书管理系统


3.备注

如有侵权请联系我删除。


4.支持博主

如果您觉得此文对您有帮助,请点赞加关注加收藏。祝您生活愉快!


相关实践学习
如何快速连接云数据库RDS MySQL
本场景介绍如何通过阿里云数据管理服务DMS快速连接云数据库RDS MySQL,然后进行数据表的CRUD操作。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
Java 开发者 微服务
Spring Boot 入门:简化 Java Web 开发的强大工具
Spring Boot 是一个开源的 Java 基础框架,用于创建独立、生产级别的基于Spring框架的应用程序。它旨在简化Spring应用的初始搭建以及开发过程。
57 6
Spring Boot 入门:简化 Java Web 开发的强大工具
|
2月前
|
Java Maven Spring
Java Web 应用中,资源文件的位置和加载方式
在Java Web应用中,资源文件如配置文件、静态文件等通常放置在特定目录下,如WEB-INF或classes。通过类加载器或Servlet上下文路径可实现资源的加载与访问。正确管理资源位置与加载方式对应用的稳定性和可维护性至关重要。
62 6
|
2月前
|
Java 持续交付 项目管理
使用Maven进行项目管理:提高Java Web开发的效率
Maven 是一款强大的项目管理和构建自动化工具,广泛应用于Java社区。它通过依赖管理、构建生命周期管理、插件机制和多模块项目支持等功能,简化了项目的构建过程,提高了开发效率。本文将介绍Maven的核心功能及其在Java Web开发中的应用。
73 0
|
5月前
|
Java 数据库连接 Maven
手把手教你如何搭建SSM框架、图书商城系统案例
这篇文章是关于如何搭建SSM框架以及实现一个图书商城系统的详细教程,包括了项目的配置文件整合、依赖管理、项目结构和运行效果展示,并提供了GitHub源码链接。
手把手教你如何搭建SSM框架、图书商城系统案例
|
4月前
|
Java 应用服务中间件 数据库连接
ssm项目整合,简单的用户管理系统
文章介绍了一个使用SSM框架(Spring、SpringMVC、MyBatis)构建的简单用户管理系统的整合过程,包括项目搭建、数据库配置、各层代码实现以及视图展示。
ssm项目整合,简单的用户管理系统
|
7月前
|
前端开发 JavaScript Java
计算机Java项目|SSM智能仓储系统
计算机Java项目|SSM智能仓储系统
|
4月前
|
XML Java 数据库连接
如何搭建SSM框架、图书商城系统
这是一份详尽的《Spring + SpringMVC + Mybatis 整合指南》,作者耗时良久整理出约五万字的内容,现已经全部笔记公开。此文档详细地介绍了如何搭建与整合SSM框架,具体步骤包括创建Maven项目、添加web骨架、配置pom文件以及整合Spring、SpringMVC和Mybatis等。无论是对初学者还是有一定基础的开发者来说,都是很好的学习资源。此外,作者还提供了项目源码的GitHub链接,方便读者实践。虽然当前主流推荐学习SpringBoot,但了解SSM框架仍然是不可或缺的基础。
59 0
|
5月前
|
SQL Java 应用服务中间件
使用SSM搭建图书商城管理系统(完整过程介绍、售后服务哈哈哈)
这篇文章是关于如何使用SSM框架搭建图书商城管理系统的教程,包括完整过程介绍、常见问题解答和售后服务,提供了项目地址、运行环境配置、效果图展示以及运行代码的步骤。
使用SSM搭建图书商城管理系统(完整过程介绍、售后服务哈哈哈)
|
6月前
|
存储 关系型数据库 测试技术
基于ssm+vue的校园驿站管理系统+(源码+部署说明+演示视频+源码介绍)(2)
基于ssm+vue的校园驿站管理系统+(源码+部署说明+演示视频+源码介绍)
102 1
|
7月前
|
前端开发
杨校老师之基于SSM开发的校园点餐配送系统
杨校老师之基于SSM开发的校园点餐配送系统
70 0
杨校老师之基于SSM开发的校园点餐配送系统