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.支持博主

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


相关实践学习
如何在云端创建MySQL数据库
开始实验后,系统会自动创建一台自建MySQL的 源数据库 ECS 实例和一台 目标数据库 RDS。
全面了解阿里云能为你做什么
阿里云在全球各地部署高效节能的绿色数据中心,利用清洁计算为万物互联的新世界提供源源不断的能源动力,目前开服的区域包括中国(华北、华东、华南、香港)、新加坡、美国(美东、美西)、欧洲、中东、澳大利亚、日本。目前阿里云的产品涵盖弹性计算、数据库、存储与CDN、分析与搜索、云通信、网络、管理与监控、应用服务、互联网中间件、移动服务、视频服务等。通过本课程,来了解阿里云能够为你的业务带来哪些帮助 &nbsp; &nbsp; 相关的阿里云产品:云服务器ECS 云服务器 ECS(Elastic Compute Service)是一种弹性可伸缩的计算服务,助您降低 IT 成本,提升运维效率,使您更专注于核心业务创新。产品详情: https://www.aliyun.com/product/ecs
相关文章
|
1月前
|
关系型数据库 MySQL Java
【IDEA】java后台操作mysql数据库驱动常见错误解决方案
【IDEA】java后台操作mysql数据库驱动常见错误解决方案
72 0
|
19天前
|
SQL XML 缓存
java中jsp详解!!!
JSP(Java Server Pages)是一种动态网页技术标准,允许在HTML页面中嵌入Java代码,实现网页逻辑与设计分离。JSP本质上是Servlet的简化,支持跨平台运行。JSP通过内置对象(如request、response、session等)和指令(如page、include、taglib)提供强大的功能,同时利用EL表达式和JSTL标签库简化页面开发。JSP的核心优势在于快速开发和维护Web应用。
35 0
|
1月前
|
SQL 存储 关系型数据库
MySQL 与 IntelliJ IDEA 同时兼容的注释
MySQL 与 IntelliJ IDEA 同时兼容的注释
30 2
|
1月前
|
数据可视化 关系型数据库 MySQL
【IDEA】配置mysql环境并创建mysql数据库
【IDEA】配置mysql环境并创建mysql数据库
118 0
|
3月前
|
缓存 安全 Java
Java服务器端技术:Servlet与JSP的集成与扩展
Java服务器端技术:Servlet与JSP的集成与扩展
36 3
|
3月前
|
存储 缓存 前端开发
Servlet与JSP在Java Web应用中的性能调优策略
Servlet与JSP在Java Web应用中的性能调优策略
34 1
|
3月前
|
关系型数据库 MySQL Linux
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
【Azure 应用服务】在创建Web App Service的时候,选Linux系统后无法使用Mysql in App
|
3月前
|
Java 数据库
使用ssm框架搭建的图书管理系统
本文介绍了使用SSM框架搭建的图书管理系统,包括图书信息管理、借阅记录管理、公告管理、出入库管理以及用户管理等功能。
使用ssm框架搭建的图书管理系统
|
3月前
|
数据采集 数据可视化 关系型数据库
【优秀python web设计】基于Python flask的猫眼电影可视化系统,可视化用echart,前端Layui,数据库用MySQL,包括爬虫
本文介绍了一个基于Python Flask框架、MySQL数据库和Layui前端框架的猫眼电影数据采集分析与可视化系统,该系统通过爬虫技术采集电影数据,利用数据分析库进行处理,并使用Echart进行数据的可视化展示,以提供全面、准确的电影市场分析结果。
134 4
|
3月前
|
存储 Java 关系型数据库
基于Servlet和JSP的Java Web应用开发指南
基于Servlet和JSP的Java Web应用开发指南
56 0
下一篇
无影云桌面