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

return modelAndView;

@RequestMapping("/admin_header.html")

public ModelAndView admin_header() {

return new ModelAndView("admin_header");

@RequestMapping("/reader_header.html")
return "redirect:/login.html";

//负责处理loginCheck.html请求

//请求参数会根据参数名称默认契约自动绑定到相应方法的入参中

@RequestMapping(value = "/api/loginCheck", method = RequestMethod.POST)

public @ResponseBody

Object loginCheck(HttpServletRequest request) {

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

String passwd = request.getParameter("passwd");

boolean isReader = loginService.hasMatchReader(id, passwd);

boolean isAdmin = loginService.hasMatchAdmin(id, passwd);

HashMap<String, String> res = new HashMap<>();

if (isAdmin) {
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)) {
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);
} else {

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

@RequestMapping("/reader_querybook_do.html")

public ModelAndView readerQueryBookDo(String searchWord) {

if (bookService.matchBook(searchWord)) {

ArrayList<Book> books = bookService.queryBook(searchWord);

ModelAndView modelAndView = new ModelAndView("reader_books");

modelAndView.addObject("books", books);

return modelAndView;

} else {

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

@RequestMapping("/admin_books.html")
long bookId = Long.parseLong(request.getParameter("bookId"));

Book book = bookService.getBook(bookId);

ModelAndView modelAndView = new ModelAndView("admin_book_edit");

modelAndView.addObject("detail", book);

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 {

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

return modelAndView;

@RequestMapping("/admin_header.html")

public ModelAndView admin_header() {

return new ModelAndView("admin_header");

@RequestMapping("/reader_header.html")

public ModelAndView reader_header() {
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) {

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

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

// 是否已归还
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);

return modelAndView;

@RequestMapping("/admin_header.html")

public ModelAndView admin_header() {

return new ModelAndView("admin_header");

@RequestMapping("/reader_header.html")

public ModelAndView reader_header() {
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) {

// 是否已归还

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

myLendList.add(lend.getBookId());

ModelAndView modelAndView = new ModelAndView("reader_books");
Admin admin = new Admin();

admin.setAdminId(id);

admin.setPassword(passwd);

String username = loginService.getAdminUsername(id);

admin.setUsername(username);

request.getSession().setAttribute("admin", admin);

res.put("stateCode", "1");

res.put("msg", "管理员登陆成功!");

} else if (isReader) {

ReaderCard readerCard = loginService.findReaderCardByReaderId(id);

request.getSession().setAttribute("readercard", readerCard);
} catch (ParseException e) {

e.printStackTrace();

readerInfo.setAddress(address);

readerInfo.setName(name);

readerInfo.setReaderId(readerId);

readerInfo.setPhone(phone);

readerInfo.setSex(sex);

readerInfo.setBirth(date);

return readerInfo;

@RequestMapping("allreaders.html")

public ModelAndView allBooks() {
res.put("stateCode", "1");

res.put("msg", "管理员登陆成功!");

} else if (isReader) {

ReaderCard readerCard = loginService.findReaderCardByReaderId(id);

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

res.put("stateCode", "2");

res.put("msg", "读者登陆成功!");

} else {

res.put("stateCode", "0");

res.put("msg", "账号或密码错误!");

return res;
public ModelAndView toReaderMain(HttpServletResponse response) {

return new ModelAndView("reader_main");

@RequestMapping("/admin_repasswd.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)) {
this.loginService = loginService;

@RequestMapping(value = {"/", "/login.html"})

public String toLogin(HttpServletRequest request) {

request.getSession().invalidate();

return "index";

@RequestMapping("/logout.html")

public String logout(HttpServletRequest request) {

request.getSession().invalidate();

return "redirect:/login.html";

//负责处理loginCheck.html请求

//请求参数会根据参数名称默认契约自动绑定到相应方法的入参中

@RequestMapping(value = "/api/loginCheck", method = RequestMethod.POST)

public @ResponseBody
res.put("msg", "管理员登陆成功!");

} else if (isReader) {

ReaderCard readerCard = loginService.findReaderCardByReaderId(id);

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

res.put("stateCode", "2");

res.put("msg", "读者登陆成功!");

} else {

res.put("stateCode", "0");

res.put("msg", "账号或密码错误!");

return res;

@RequestMapping("/admin_main.html")

public ModelAndView toAdminMain(HttpServletResponse response) {

return new ModelAndView("admin_main");

JAVAlibrary图书馆官网_javascript


JAVAlibrary图书馆官网_JAVAlibrary图书馆官网_02


JAVAlibrary图书馆官网_javascript_03


JAVAlibrary图书馆官网_mysql_04


JAVAlibrary图书馆官网_html_05


JAVAlibrary图书馆官网_javascript_06