基于javaweb+mysql的ssm图书管理系统(java+ssm+jsp+jquery+mysql)

基于javaweb+mysql的ssm图书管理系统(java+ssm+jsp+jquery+mysql)

运行环境

Java≥8、MySQL≥5.7、Tomcat≥8

开发工具

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

适用

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

功能说明

基于javaweb+mysql的SSM图书管理系统(java+ssm+jsp+jquery+mysql)

项目介绍

本图书馆管理系统主要分为前台和后台两大功能模块,共包含两种角色,分别是:读者、管理员。

其功能如下: 1.前台功能 前台首页、网站公告、图书浏览、图书详情、图书搜索、图书分类展示、推荐图书、全部图书、预约图书、图书借阅、图书评论、收藏图书、用户注册、用户登陆、用户中心、修改个人信息、修改密码、我的借阅历史、我的收藏、我的意见反馈、退出等功能。 2.后台功能 后台系统登陆、用户信息管理、新闻公告信息管理、图书类型管理、图书信息管理、图书预约管理、延期申请管理、图书评价管理、意见反馈管理、统计信息等功能。

环境需要

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等版本均可;

技术栈

后台框架:Spring、SpringMVC、MyBatis UI界面:JSP、jQuery 数据库:MySQL

使用说明

  1. 使用Navicat或者其它工具,在mysql中创建对应名称的数据库,并导入项目的sql文件;

  2. 使用IDEA/Eclipse/MyEclipse导入项目,修改配置,运行项目;

@Controller

public class BookController {

@Autowired

private BookService bookService;

@Autowired

private LendService lendService;

private Date getDate(String pubstr) {

try {

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

return df.parse(pubstr);


@Autowired

private ReaderCardService readerCardService;

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);


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);

ModelAndView modelAndView = new ModelAndView("admin_book_detail");

modelAndView.addObject("detail", book);

return modelAndView;

@RequestMapping("/reader_book_detail.html")

public ModelAndView readerBookDetail(HttpServletRequest request) {

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

Book book = bookService.getBook(bookId);
ArrayList<Long> myLendList = new ArrayList<>();

for (Lend lend : myAllLendList) {

// 是否已归还

if (lend.getBackDate() == null) {

myLendList.add(lend.getBookId());

ModelAndView modelAndView = new ModelAndView("reader_books");

modelAndView.addObject("books", books);

modelAndView.addObject("myLendList", myLendList);

return modelAndView;

借阅管理控制层:

@Controller

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

return "redirect:/admin_books.html";

@RequestMapping("/lendlist.html")

public ModelAndView lendList(HttpServletRequest request) {

ModelAndView modelAndView = new ModelAndView("admin_lend_list");

modelAndView.addObject("list", lendService.lendList());

return modelAndView;

@RequestMapping("/mylend.html")

public ModelAndView myLend(HttpServletRequest request) {

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

ModelAndView modelAndView = new ModelAndView("reader_lend_list");

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);

ModelAndView modelAndView = new ModelAndView("reader_books");

modelAndView.addObject("books", books);

return modelAndView;

} else {

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")


ModelAndView modelAndView = new ModelAndView("reader_books");

modelAndView.addObject("books", books);

modelAndView.addObject("myLendList", myLendList);

return modelAndView;

借阅管理控制层:

@Controller

public class LendController {

@Autowired

private LendService lendService;

@Autowired

private BookService bookService;

@RequestMapping("/deletebook.html")

public String deleteBook(HttpServletRequest request, RedirectAttributes redirectAttributes) {


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);

ModelAndView modelAndView = new ModelAndView("admin_book_detail");

modelAndView.addObject("detail", book);

return modelAndView;

@RequestMapping("/reader_book_detail.html")

public ModelAndView readerBookDetail(HttpServletRequest request) {

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

if (lend.getBackDate() == null) {

myLendList.add(lend.getBookId());

ModelAndView modelAndView = new ModelAndView("reader_books");

modelAndView.addObject("books", books);

modelAndView.addObject("myLendList", myLendList);

return modelAndView;

借阅管理控制层:

@Controller

public class LendController {

@Autowired

private LendService lendService;

@Autowired

private BookService bookService;

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", "读者信息修改成功!");

ReaderInfo readerInfo = getReaderInfo(readerCard.getReaderId(), name, sex, birth, address, phone);

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

ReaderCard readerCardNew = loginService.findReaderCardByReaderId(readerCard.getReaderId());

request.getSession().setAttribute("readercard", readerCardNew);

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

} else {

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

return "redirect:/reader_info.html";

图书管理控制层:

@Controller

public class BookController {


if (bookService.deleteBook(bookId)) {

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

} else {

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

return "redirect:/admin_books.html";

@RequestMapping("/lendlist.html")

public ModelAndView lendList(HttpServletRequest request) {

ModelAndView modelAndView = new ModelAndView("admin_lend_list");

modelAndView.addObject("list", lendService.lendList());

return modelAndView;

@RequestMapping("/mylend.html")


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

return "redirect:/allreaders.html";

@RequestMapping("reader_info_edit.html")

public ModelAndView readerInfoEditReader(HttpServletRequest request) {

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

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

ModelAndView modelAndView = new ModelAndView("reader_info_edit");

modelAndView.addObject("readerinfo", readerInfo);

return modelAndView;

@RequestMapping("reader_edit_do_r.html")

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


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 readerInfoEdit(HttpServletRequest request) {

long readerId = Long.parseLong(request.getParameter("readerId"));
ArrayList<Long> myLendList = new ArrayList<>();

for (Lend lend : myAllLendList) {

// 是否已归还

if (lend.getBackDate() == null) {

myLendList.add(lend.getBookId());

ModelAndView modelAndView = new ModelAndView("reader_books");

modelAndView.addObject("books", books);

modelAndView.addObject("myLendList", myLendList);

return modelAndView;

借阅管理控制层:

@Controller

public class LendController {

@Autowired

@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 (bookService.addBook(book)) {

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

} else {

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

return "redirect:/admin_books.html";

@RequestMapping("/updatebook.html")

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

Book book = bookService.getBook(bookId);

ModelAndView modelAndView = new ModelAndView("admin_book_detail");

modelAndView.addObject("detail", book);

return modelAndView;

@RequestMapping("/reader_book_detail.html")

public ModelAndView readerBookDetail(HttpServletRequest request) {

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

Book book = bookService.getBook(bookId);

ModelAndView modelAndView = new ModelAndView("reader_book_detail");

modelAndView.addObject("detail", book);

请添加图片描述

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