JavaWeb图书管理系统
1.项目简单介绍
a.项目用到的技术
- IDE: Intellij IDEA
- 语言:java,html + ajax,js
- 数据库:Mysql
- 数据库可视化: navicat
- web服务器:Tomcat
- 框架:(mybatis,jquery,bootstrap)
- 项目用到maven
- 设计模式:MVC
b.该项目的主要功能
- 管理员与普通用户分为不同界面
- 管理员和普通用户可修改个人信息
- 管理员和普通用户注销
- 管理员和普通用户密码(MD5加密)
- 借书,还书操作(并检测还书是否逾期)
- 图书的添加(考虑到图书类型的扩展),修改
- 图书的删除(物理删除和逻辑删除可选)
- 公共图书库查看(分页查询实现)
- 图书查询(多条件和模糊两种)
- 管理员查看用户借书信息,可看是否按时还书
2.项目展示
a. 普通用户功能
(1)查询(多条件和模糊查询)
(2) 个人图书库
(3)用户修改信息界面(有过渡效果)
(4)普通用户界面展示
b . 管理员功能
(1)增加图书
(2)删除图书(物理删除和逻辑删除)
(3)图书修改(回显)
(4)图书查询
(5)查看用户借书记录并查看是否还书逾期
(6)用户管理(逻辑删除)
(7)公共图书库(分页查询)
3.项目讲解
a . 项目基本结构
![Alt]
b . maven导入依赖
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.example</groupId>
<artifactId>javaWeb_example</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<dependencies>
<!--jstl-->
<dependency>
<groupId>jstl</groupId>
<artifactId>jstl</artifactId>
<version>1.2</version>
</dependency>
<dependency>
<groupId>taglibs</groupId>
<artifactId>standard</artifactId>
<version>1.1.2</version>
</dependency>
<!--servlet-->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.1.0</version>
<scope>provided</scope>
</dependency>
<!--mybatis-->
<dependency>
<groupId>org.mybatis</groupId>
<artifactId>mybatis</artifactId>
<version>3.5.6</version>
</dependency>
<dependency>
<groupId>mysql</groupId>
<artifactId>mysql-connector-java</artifactId>
<version>5.1.47</version>
</dependency>
<!--FASTJSON-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>1.2.62</version>
</dependency>
<!--密码加密-->
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.10</version>
</dependency>
<!--HuTool-->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.7.22</version>
</dependency>
</dependencies>
<!--tomcat插件-->
<build>
<plugins>
<plugin>
<groupId>org.apache.tomcat.maven</groupId>
<artifactId>tomcat7-maven-plugin</artifactId>
<version>2.2</version>
<configuration>
<port>80</port>
<path>/</path>
</configuration>
</plugin>
</plugins>
</build>
</project>
c . 数据库Mysql表
d. javabean中对应的实体类
e . servlet层中的loginservlet(登录后端服务)
package com.servlet;
import com.alibaba.fastjson.JSON;
import com.bean.User;
import com.bean.admin;
import com.service.impl.UserServiceImpl;
import com.util.DateAdd;
import com.util.MD5BU;
import com.util.ZhUtils;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
@WebServlet("/login/*")
public class LoginServlet extends BaseServlet{
private UserServiceImpl userService = new UserServiceImpl();
//登录
public void log(HttpServletRequest req, HttpServletResponse resp) throws Exception {
HttpSession session = req.getSession();
String username = req.getParameter("username");
String password = req.getParameter("password");
User user = userService.select(username,MD5BU.md5(password));
if(user != null){
user.setPassword(password);
req.setAttribute("isUser",0);
session.setAttribute("user",user);
String s = session.getId();
Cookie cookie = new Cookie("sessionId",s);
cookie.setPath("/");
resp.addCookie(cookie);
if(user.root == 1){
resp.sendRedirect("/web_root.jsp");
}
else {
resp.sendRedirect("http://localhost/web_main.jsp");
}
}
else {
req.setAttribute("isUser",1);
req.getRequestDispatcher("/login.jsp").forward(req,resp);
}
}
//注册
public void register(HttpServletRequest req, HttpServletResponse resp) throws Exception{
String username = req.getParameter("username");
String password = req.getParameter("password");
User user = userService.selectOneByUsername(username);
if(user != null){
resp.getWriter().write("true");
}
else {
if(username != "" && password != ""){
password = MD5BU.md5(password);
userService.register(username,password);
resp.sendRedirect("/login.jsp");
}
}
}
//个人图书库
public void library(HttpServletRequest req, HttpServletResponse resp) throws IOException {
req.setCharacterEncoding("utf-8");
String username = ZhUtils.getZh(req.getParameter("username"));
int userid = Integer.parseInt(req.getParameter("userid"));
String bookname = ZhUtils.getZh(req.getParameter("bookname"));
int bookid = Integer.parseInt(req.getParameter("bookid"));
DateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String dateTime = dateFormat.format(date);
String bookAuthor = ZhUtils.getZh(req.getParameter("bookAuthor"));
String bookType = ZhUtils.getZh(req.getParameter("bookType"));
String date_Hope = dateFormat.format(DateAdd.addDays(date, 7));
int num = Integer.parseInt(req.getParameter("num"));
userService.usBkConnect(username,userid,bookname,bookid,dateTime,bookAuthor,bookType,date_Hope);
resp.setContentType("text/json;charset=utf-8");
resp.getWriter().write("添加成功~");
}
//注销
public void logout (HttpServletRequest req, HttpServletResponse resp) throws IOException {
req.getSession().invalidate();
resp.sendRedirect("/login.jsp");
}
//查询所有管理员
public void selectAdminAll (HttpServletRequest req, HttpServletResponse resp) throws IOException{
List<admin> admins = userService.selectAdminAll();
String jsonString = JSON.toJSONString(admins);
resp.setContentType("text/json;charset=utf-8");
resp.getWriter().write(jsonString);
}
}
f . 图书模糊查询功能(ajax)
//模糊查询
let blurred_btn = document.getElementById("blurred_btn");
let blurredBookName = document.getElementById("seaName");
blurred_btn.onclick = function (){
if (blurredBookName.value){
axios({
method:"get",
url:"http://localhost/book/blurredQuery?bookName="+blurredBookName.value
}).then(function (resp) {
let resultBooks = resp.data;
createTableSearch(resultBooks);
})
}
else {
alert("请填写完整信息!")
}
}
附上源码 (压缩包大小15.1M)
网盘网址:https://pan.baidu.com/s/1zB1sASQHow7WgxRLOKQSiA?pwd=wzyb
提取码: wzyb文章来源:https://www.toymoban.com/news/detail-458834.html
sql文件: 链接: https://pan.baidu.com/s/1VqC0cwq4pEc8pDwvL4xREA?pwd=aaaa 提取码: aaaa文章来源地址https://www.toymoban.com/news/detail-458834.html
到了这里,关于javaWeb图书管理系统的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!