基于javaweb+mysql的ssm图书馆管理系统(java+html+ssm+javascript+layui+mysql)

基于javaweb+mysql的ssm图书馆管理系统(java+html+ssm+javascript+layui+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

eclipse/idea/myeclipse/sts等均可配置运行

适用

课程设计,大作业,毕业设计,项目练习,学习演示等

功能说明

基于javaweb+mysql的SSM图书馆管理系统(java+html+ssm+javascript+layui+mysql)

项目介绍

SSM图书馆管理系统,角色:管理员和读者。 管理员角色功能如下: 登录、图书管理、读者管理、公告管理、借阅管理、类型管理、首页、统计分析、图书馆系统、修改密码

读者角色功能如下: 登录、公告管理、借阅管理、修改密码;

环境需要:

1.运行环境:最好是java jdk 1.8,我们在这个平台上运行的。其他版本理论上也可以。 2.IDE环境:IDEA,Eclipse,Myeclipse都可以。推荐IDEA; 3.tomcat环境:Tomcat 7.x,8.x,9.x版本均可 4.硬件环境:windows 7/8/10 1G内存以上;或者 Mac OS; 5.是否Maven项目: 否;查看源码目录中是否包含pom.xml;若包含,则为maven项目,否则为非maven项目 6.数据库:MySql 5.7/8.0等版本均可;

技术栈:

后端:SSM(Spring+SpringMVC+Mybatis) 前端:HTML+CSS+Javascript+Layui

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应sql文件名称的数据库,并导入项目的sql文件; 2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目; 3. 将项目中db.properties配置文件中的数据库配置改为自己的配置,然后运行; 4. 在浏览器中输入http://localhost:8080/LibraryProject/login 管理员用户名密码:admin/12345 读者用户名密码:zhangsan/12345
@RequestMapping("/book_edit_do.html")

public String bookEditDo(@RequestParam(value = "pubstr") String pubstr, Book book, RedirectAttributes redirectAttributes) {

book.setPubdate(getDate(pubstr));

if (bookService.editBook(book)) {

redirectAttributes.addFlashAttribute("succ", "图书修改成功!");

} else {

redirectAttributes.addFlashAttribute("error", "图书修改失败!");

return "redirect:/admin_books.html";

@RequestMapping("/admin_book_detail.html")

public ModelAndView adminBookDetail(HttpServletRequest request) {

long bookId = Long.parseLong(request.getParameter("bookId"));


return new ModelAndView("reader_books", "error", "没有匹配的图书");

@RequestMapping("/admin_books.html")

public ModelAndView adminBooks() {

ArrayList<Book> books = bookService.getAllBooks();

ModelAndView modelAndView = new ModelAndView("admin_books");

modelAndView.addObject("books", books);

return modelAndView;

@RequestMapping("/book_add.html")

public ModelAndView addBook() {

return new ModelAndView("admin_book_add");

@RequestMapping("/book_add_do.html")

public String addBookDo(@RequestParam(value = "pubstr") String pubstr, Book book, RedirectAttributes redirectAttributes) {

book.setPubdate(getDate(pubstr));


if (readerInfoService.deleteReaderInfo(readerId) && readerCardService.deleteReaderCard(readerId)) {

redirectAttributes.addFlashAttribute("succ", "删除成功!");

} else {

redirectAttributes.addFlashAttribute("error", "删除失败!");

return "redirect:/allreaders.html";

@RequestMapping("/reader_info.html")

public ModelAndView toReaderInfo(HttpServletRequest request) {

ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");

ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerCard.getReaderId());

ModelAndView modelAndView = new ModelAndView("reader_info");

modelAndView.addObject("readerinfo", readerInfo);

return modelAndView;

@RequestMapping("reader_edit.html")


public ModelAndView reAdminPasswd() {

return new ModelAndView("admin_repasswd");

@RequestMapping("/admin_repasswd_do")

public String reAdminPasswdDo(HttpServletRequest request, String oldPasswd, String newPasswd, String reNewPasswd, RedirectAttributes redirectAttributes) {

Admin admin = (Admin) request.getSession().getAttribute("admin");

long id = admin.getAdminId();

String password = loginService.getAdminPassword(id);

if (password.equals(oldPasswd)) {

if (loginService.adminRePassword(id, newPasswd)) {

redirectAttributes.addFlashAttribute("succ", "密码修改成功!");

return "redirect:/admin_repasswd.html";

} else {


long id = admin.getAdminId();

String password = loginService.getAdminPassword(id);

if (password.equals(oldPasswd)) {

if (loginService.adminRePassword(id, newPasswd)) {

redirectAttributes.addFlashAttribute("succ", "密码修改成功!");

return "redirect:/admin_repasswd.html";

} else {

redirectAttributes.addFlashAttribute("error", "密码修改失败!");

return "redirect:/admin_repasswd.html";

} else {

redirectAttributes.addFlashAttribute("error", "旧密码错误!");


public ModelAndView admin_header() {

return new ModelAndView("admin_header");

@RequestMapping("/reader_header.html")

public ModelAndView reader_header() {

return new ModelAndView("reader_header");

@RequestMapping("/reader_books.html")

public ModelAndView readerBooks(HttpServletRequest request) {

ArrayList<Book> books = bookService.getAllBooks();

ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");

ArrayList<Lend> myAllLendList = lendService.myLendList(readerCard.getReaderId());

ArrayList<Long> myLendList = new ArrayList<>();

for (Lend lend : myAllLendList) {

// 是否已归还

ReaderCard reader = (ReaderCard) request.getSession().getAttribute("readercard");

long id = reader.getReaderId();

String password = loginService.getReaderPassword(id);

if (password.equals(oldPasswd)) {

if (loginService.readerRePassword(id, newPasswd)) {

redirectAttributes.addFlashAttribute("succ", "密码修改成功!");

return "redirect:/reader_repasswd.html";

} else {

redirectAttributes.addFlashAttribute("error", "密码修改失败!");

return "redirect:/reader_repasswd.html";

} else {


return "redirect:/allreaders.html";

@RequestMapping("/reader_info.html")

public ModelAndView toReaderInfo(HttpServletRequest request) {

ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");

ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerCard.getReaderId());

ModelAndView modelAndView = new ModelAndView("reader_info");

modelAndView.addObject("readerinfo", readerInfo);

return modelAndView;

@RequestMapping("reader_edit.html")

public ModelAndView readerInfoEdit(HttpServletRequest request) {

long readerId = Long.parseLong(request.getParameter("readerId"));

ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerId);

ModelAndView modelAndView = new ModelAndView("admin_reader_edit");

@RequestMapping("reader_add_do.html")

public String readerInfoAddDo(String name, String sex, String birth, String address, String phone, String password, RedirectAttributes redirectAttributes) {

ReaderInfo readerInfo = getReaderInfo(0, name, sex, birth, address, phone);

long readerId = readerInfoService.addReaderInfo(readerInfo);

readerInfo.setReaderId(readerId);

if (readerId > 0 && readerCardService.addReaderCard(readerInfo, password)) {

redirectAttributes.addFlashAttribute("succ", "添加读者信息成功!");

} else {

redirectAttributes.addFlashAttribute("succ", "添加读者信息失败!");

return "redirect:/allreaders.html";


return new ModelAndView("admin_book_add");

@RequestMapping("/book_add_do.html")

public String addBookDo(@RequestParam(value = "pubstr") String pubstr, Book book, RedirectAttributes redirectAttributes) {

book.setPubdate(getDate(pubstr));

if (bookService.addBook(book)) {

redirectAttributes.addFlashAttribute("succ", "图书添加成功!");

} else {

redirectAttributes.addFlashAttribute("succ", "图书添加失败!");

return "redirect:/admin_books.html";

@RequestMapping("/updatebook.html")

public ModelAndView bookEdit(HttpServletRequest request) {

long bookId = Long.parseLong(request.getParameter("bookId"));


ReaderInfo readerInfo = getReaderInfo(readerId, name, sex, birth, address, phone);

if (readerInfoService.editReaderInfo(readerInfo) && readerInfoService.editReaderCard(readerInfo)) {

redirectAttributes.addFlashAttribute("succ", "读者信息修改成功!");

} else {

redirectAttributes.addFlashAttribute("error", "读者信息修改失败!");

return "redirect:/allreaders.html";

@RequestMapping("reader_add.html")

public ModelAndView readerInfoAdd() {

return new ModelAndView("admin_reader_add");

@RequestMapping("reader_add_do.html")

public String readerInfoAddDo(String name, String sex, String birth, String address, String phone, String password, RedirectAttributes redirectAttributes) {

ReaderInfo readerInfo = getReaderInfo(0, name, sex, birth, address, phone);

long readerId = readerInfoService.addReaderInfo(readerInfo);


private ReaderInfo getReaderInfo(long readerId, String name, String sex, String birth, String address, String phone) {

ReaderInfo readerInfo = new ReaderInfo();

Date date = new Date();

try {

SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");

date = df.parse(birth);

} catch (ParseException e) {

e.printStackTrace();

readerInfo.setAddress(address);

readerInfo.setName(name);

readerInfo.setReaderId(readerId);

readerInfo.setPhone(phone);

readerInfo.setSex(sex);

public ModelAndView admin_header() {

return new ModelAndView("admin_header");

@RequestMapping("/reader_header.html")

public ModelAndView reader_header() {

return new ModelAndView("reader_header");

@RequestMapping("/reader_books.html")

public ModelAndView readerBooks(HttpServletRequest request) {

ArrayList<Book> books = bookService.getAllBooks();

ReaderCard readerCard = (ReaderCard) request.getSession().getAttribute("readercard");

ArrayList<Lend> myAllLendList = lendService.myLendList(readerCard.getReaderId());

ArrayList<Long> myLendList = new ArrayList<>();

for (Lend lend : myAllLendList) {


redirectAttributes.addFlashAttribute("error", "旧密码错误!");

return "redirect:/admin_repasswd.html";

@RequestMapping("/reader_repasswd.html")

public ModelAndView reReaderPasswd() {

return new ModelAndView("reader_repasswd");

@RequestMapping("/reader_repasswd_do")

public String reReaderPasswdDo(HttpServletRequest request, String oldPasswd, String newPasswd, String reNewPasswd, RedirectAttributes redirectAttributes) {

ReaderCard reader = (ReaderCard) request.getSession().getAttribute("readercard");

long id = reader.getReaderId();

String password = loginService.getReaderPassword(id);

if (password.equals(oldPasswd)) {

if (loginService.readerRePassword(id, newPasswd)) {

redirectAttributes.addFlashAttribute("succ", "密码修改成功!");


public ModelAndView readerInfoEdit(HttpServletRequest request) {

long readerId = Long.parseLong(request.getParameter("readerId"));

ReaderInfo readerInfo = readerInfoService.getReaderInfo(readerId);

ModelAndView modelAndView = new ModelAndView("admin_reader_edit");

modelAndView.addObject("readerInfo", readerInfo);

return modelAndView;

@RequestMapping("reader_edit_do.html")

public String readerInfoEditDo(HttpServletRequest request, String name, String sex, String birth, String address, String phone, RedirectAttributes redirectAttributes) {

long readerId = Long.parseLong(request.getParameter("readerId"));

ReaderInfo readerInfo = getReaderInfo(readerId, name, sex, birth, address, phone);

if (readerInfoService.editReaderInfo(readerInfo) && readerInfoService.editReaderCard(readerInfo)) {

redirectAttributes.addFlashAttribute("succ", "读者信息修改成功!");

redirectAttributes.addFlashAttribute("succ", "密码修改成功!");

return "redirect:/admin_repasswd.html";

} else {

redirectAttributes.addFlashAttribute("error", "密码修改失败!");

return "redirect:/admin_repasswd.html";

} else {

redirectAttributes.addFlashAttribute("error", "旧密码错误!");

return "redirect:/admin_repasswd.html";

@RequestMapping("/reader_repasswd.html")

public ModelAndView reReaderPasswd() {

return new ModelAndView("reader_repasswd");

@RequestMapping("/reader_repasswd_do")

public String reReaderPasswdDo(HttpServletRequest request, String oldPasswd, String newPasswd, String reNewPasswd, RedirectAttributes redirectAttributes) {


return modelAndView;

@RequestMapping("/book_edit_do.html")

public String bookEditDo(@RequestParam(value = "pubstr") String pubstr, Book book, RedirectAttributes redirectAttributes) {

book.setPubdate(getDate(pubstr));

if (bookService.editBook(book)) {

redirectAttributes.addFlashAttribute("succ", "图书修改成功!");

} else {

redirectAttributes.addFlashAttribute("error", "图书修改失败!");

return "redirect:/admin_books.html";

@RequestMapping("/admin_book_detail.html")

public ModelAndView adminBookDetail(HttpServletRequest request) {

long bookId = Long.parseLong(request.getParameter("bookId"));

Book book = bookService.getBook(bookId);

请添加图片描述

请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述
请添加图片描述

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值