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

本文涉及的产品
云数据库 RDS MySQL Serverless,0.5-2RCU 50GB
简介: 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.支持博主

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


相关实践学习
基于CentOS快速搭建LAMP环境
本教程介绍如何搭建LAMP环境,其中LAMP分别代表Linux、Apache、MySQL和PHP。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
18天前
|
存储 Java 关系型数据库
个人成绩信息管理系统【GUI/Swing+MySQL】(Java课设)
个人成绩信息管理系统【GUI/Swing+MySQL】(Java课设)
20 0
|
18天前
|
存储 Java 关系型数据库
社区医院管理服务系统【GUI/Swing+MySQL】(Java课设)
社区医院管理服务系统【GUI/Swing+MySQL】(Java课设)
24 1
|
18天前
|
存储 Java 关系型数据库
实验室设备管理系统【GUI/Swing+MySQL】(Java课设)
实验室设备管理系统【GUI/Swing+MySQL】(Java课设)
17 0
|
18天前
|
存储 Java 关系型数据库
冬奥会传统文化管理系统【GUI/Swing+MySQL】(Java课设)
冬奥会传统文化管理系统【GUI/Swing+MySQL】(Java课设)
8 0
|
1天前
|
Java 关系型数据库 MySQL
一套java+ spring boot与vue+ mysql技术开发的UWB高精度工厂人员定位全套系统源码有应用案例
UWB (ULTRA WIDE BAND, UWB) 技术是一种无线载波通讯技术,它不采用正弦载波,而是利用纳秒级的非正弦波窄脉冲传输数据,因此其所占的频谱范围很宽。一套UWB精确定位系统,最高定位精度可达10cm,具有高精度,高动态,高容量,低功耗的应用。
一套java+ spring boot与vue+ mysql技术开发的UWB高精度工厂人员定位全套系统源码有应用案例
|
4天前
|
Web App开发 Java 应用服务中间件
【Java Web】在 IDEA 中部署 Tomcat
【Java Web】在 IDEA 中部署 Tomcat
20 0
|
7天前
|
Java 应用服务中间件 Maven
使用IDEA搭建SpringMVC环境,Maven导入了依赖,但是运行报错 java.lang.ClassNotFoundException
使用IDEA搭建SpringMVC环境,Maven导入了依赖,但是运行报错 java.lang.ClassNotFoundException
8 1
|
10天前
|
监控 数据可视化 安全
智慧工地SaaS可视化平台源码,PC端+APP端,支持二开,项目使用,微服务+Java++vue+mysql
环境实时数据、动态监测报警,实时监控施工环境状态,有针对性地预防施工过程中的环境污染问题,打造文明生态施工,创造绿色的生态环境。
8 0
智慧工地SaaS可视化平台源码,PC端+APP端,支持二开,项目使用,微服务+Java++vue+mysql
|
11天前
|
Java 数据库连接 Maven
ssm整合idea版本
ssm整合idea版本
|
16天前
|
JavaScript Java 关系型数据库
基于 java + Springboot + vue +mysql 大学生实习管理系统(含源码)
本文档介绍了基于Springboot的实习管理系统的设计与实现。系统采用B/S架构,旨在解决实习管理中的人工管理问题,提高效率。系统特点包括对用户输入的验证和数据安全性保障。功能涵盖首页、个人中心、班级管理、学生管理、教师管理、实习单位管理、实习作业管理、教师评分管理、单位成绩管理和系统管理等。用户分为管理员、教师和学生,各自有不同的操作权限。