5.工程截图
二、系统展示
=======
1.登录系统
2.主页面
3.图书列表
4.图书详情
5.编辑删除
6.添加图书
7.图书借阅
8.图书归还
9.借阅记录
10.用户管理
三、部分代码
=======
BookAction
package Action;
import Dao.BookDao;
import Entity.Book;
import Entity.User;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
public class BookAction extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
request.setCharacterEncoding(“UTF-8”);
response.setCharacterEncoding(“UTF-8”);
String action = request.getParameter(“action”);
if (action.equals(“getall”)) {
this.getAll(request, response);
} else if (action.equals(“addtemp”)) {
this.addtemp(request, response);
} else if (action.equals(“gettemp”)) {
this.gettemp(request, response);
} else if (action.equals(“confirm”)) {
this.confirm(request, response);
} else if (action.equals(“querybookbyid”)) {
this.QueryBookById(request, response);
} else if (action.equals(“DeleteById”)) {
this.DeleteById(request, response);
} else if (action.equals(“EditDone”)) {
this.EditDone(request, response);
}
}
private void getAll(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BookDao bdao = new BookDao();
ArrayList bookArrayList = bdao.getAllBook();
HttpSession session = request.getSession();
session.setAttribute(“allbooklist”, bookArrayList);
request.getRequestDispatcher(“/book-list.jsp”).forward(request, response);
}
private void addtemp(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String next = request.getParameter(“over”);
BookDao bdao = new BookDao();
Book book = new Book();
if (!request.getParameter(“bookid”).equals(“”))
book.setId(request.getParameter(“bookid”));
if (!request.getParameter(“bookname”).equals(“”))
book.setName(request.getParameter(“bookname”));
if (!request.getParameter(“bookauthor”).equals(“”))
book.setAuthor(request.getParameter(“bookauthor”));
if (!request.getParameter(“bookpublisher”).equals(“”))
book.setPublisher(request.getParameter(“bookpublisher”));
if (!request.getParameter(“bookcategory”).equals(“”))
book.setCategory(request.getParameter(“bookcategory”));
if (!request.getParameter(“bookprice”).trim().equals(“”))
book.setPrice(Integer.parseInt(request.getParameter(“bookprice”)));
if (!request.getParameter(“bookstore”).trim().equals(“”))
book.setStore(Integer.parseInt(request.getParameter(“bookstore”)));
if (!request.getParameter(“booklocation”).equals(“”))
book.setLocation(request.getParameter(“booklocation”));
if (!request.getParameter(“bookdesc”).equals(“”))
book.setDesc(request.getParameter(“bookdesc”));
if (!request.getParameter(“bookid”).equals(“”))
bdao.addtemp(book);
if (next.equals(“0”))
request.getRequestDispatcher(“/add-book.jsp”).forward(request, response);
else
this.gettemp(request, response);
}
private void gettemp(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BookDao bdao = new BookDao();
ArrayList addbooklist = bdao.getadd();
HttpSession session = request.getSession();
session.setAttribute(“addbooklist”, addbooklist);
request.getRequestDispatcher(“/add-confirm.jsp”).forward(request, response);
}
private void confirm(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BookDao bdao = new BookDao();
bdao.confirm();
this.getAll(request, response);
}
private void QueryBookById(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BookDao bdao = new BookDao();
String id = request.getParameter(“id”);
String next = request.getParameter(“next”);
Book book = bdao.QueryBookById(id);
HttpSession session = request.getSession();
session.setAttribute(“resultbook”, book);
PrintWriter out = response.getWriter();
if (next.equals(“check”))
request.getRequestDispatcher(“/detail.jsp”).forward(request, response);
else if (next.equals(“edit”))
request.getRequestDispatcher(“/edit-book.jsp”).forward(request, response);
else if (next.equals(“borrowcheck”)) {
out.write(book.getName() + “||” + book.getAuthor() + “||” + book.getPublisher() + “||” + book.getRemain());
}
}
private void DeleteById(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BookDao bdao = new BookDao();
String id = request.getParameter(“id”);
bdao.DeleteById(id);
this.getAll(request, response);
}
private void EditDone(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
BookDao bdao = new BookDao();
Book book = new Book();
if (!request.getParameter(“id”).equals(“”))
book.setId(request.getParameter(“id”));
if (!request.getParameter(“name”).equals(“”))
book.setName(request.getParameter(“name”));
if (!request.getParameter(“author”).equals(“”))
book.setAuthor(request.getParameter(“author”));
if (!request.getParameter(“publisher”).equals(“”))
book.setPublisher(request.getParameter(“publisher”));
if (!request.getParameter(“category”).equals(“”))
book.setCategory(request.getParameter(“category”));
if (!request.getParameter(“price”).trim().equals(“”))
book.setPrice(Integer.parseInt(request.getParameter(“price”)));
if (!request.getParameter(“store”).trim().equals(“”))
book.setStore(Integer.parseInt(request.getParameter(“store”)));
if (!request.getParameter(“location”).equals(“”))
book.setLocation(request.getParameter(“location”));
if (!request.getParameter(“desc”).equals(“”))
book.setDesc(request.getParameter(“desc”));
if (!request.getParameter(“id”).equals(“”))
bdao.addtemp(book);
bdao.EditDone(book);
request.getRequestDispatcher(“BookAction?action=querybookbyid&id=<%=b.getId()%>&next=check”).forward(request, response);
}
}
IOAction
package Action;
import Dao.IODao;
import Entity.Log;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
public class IOAction extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String action = request.getParameter(“action”);
if (action.equals(“borrow”)) {
this.borrow(request, response);
} else if (action.equals(“getlog”)) {
this.getlog(request, response);
} else if (action.equals(“return”)) {
this.ReturnBook(request, response);
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
this.doPost(request, response);
}
protected void borrow(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
IODao ioDao = new IODao();
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy年MM月dd日 HH时mm分ss秒”);
Date date = new Date();
String time = sdf.format(date);
String readerid = request.getParameter(“readerid”);
String bookid = request.getParameter(“bookid”);
int borrowday = Integer.parseInt(request.getParameter(“borrowday”));
ioDao.borrow(bookid, readerid, time, borrowday);
this.getlog(request, response);
}
protected void getlog(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
IODao ioDao = new IODao();
ArrayList loglist = ioDao.getLogList();
HttpSession session = request.getSession();
session.setAttribute(“loglist”, loglist);
request.getRequestDispatcher(“/io-log.jsp”).forward(request, response);
}
protected void ReturnBook(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
IODao ioDao = new IODao();
SimpleDateFormat sdf = new SimpleDateFormat(“yyyy年MM月dd日 HH时mm分ss秒”);
Date date = new Date();
String Returntime = sdf.format(date);
String bookid = request.getParameter(“bookid”);
String readerId = request.getParameter(“ReaderId”);
String borrowtime = request.getParameter(“borrowtime”);
ioDao.ReturnBook(bookid, readerId, borrowtime, Returntime);
this.getlog(request, response);
}
}
LoginAction
package Action;
import Dao.UserDao;
import Entity.User;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
public class LoginAction extends HttpServlet {
UserDao udao = new UserDao();
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String action = request.getParameter(“action”);
if (action.equals(“login”)) {
this.login(request, response);
} else if (action.equals(“logout”)) {
this.logout(request, response);
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
private void login(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String username = null;
String password = null;
PrintWriter out = response.getWriter();
HttpSession session = request.getSession();
username = request.getParameter(“username”);
password = request.getParameter(“password”);
User user = new User();
user.setUsername(username);
user.setPassword(password);
String result = udao.login(user);
if (result.equals(“true”)) {
session.setAttribute(“adminname”, user.getName());
request.getRequestDispatcher(“/main.jsp”).forward(request, response);
} else {
out.write(result);
}
}
private void logout(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
HttpSession session = request.getSession();
session.setMaxInactiveInterval(1);
response.sendRedirect(“/index.jsp”);
}
}
ReaderAction
package Action;
/**
- 读者管理
*/
import Dao.IODao;
import Dao.ReaderDao;
import Entity.Log;
import Entity.Reader;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.ArrayList;
public class ReaderAction extends HttpServlet {
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String action = request.getParameter(“action”);
request.setCharacterEncoding(“UTF-8”);
response.setCharacterEncoding(“UTF-8”);
response.setContentType(“text/html; charset=utf-8”);
if (action.equals(“QueryReaderById”)) {
this.QueryReaderById(request, response);
} else if (action.equals(“GetBorrowListById”)) {
this.GetBorrowListById(request, response);
} else if (action.equals(“GetAllReader”)) {
this.GetAllReader(request, response);
} else if (action.equals(“SetBlackList”)) {
this.SetBlackList(request, response);
}
}
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doPost(request, response);
}
protected void QueryReaderById(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
String readerid = request.getParameter(“readerid”);
小编13年上海交大毕业,曾经在小公司待过,也去过华为、OPPO等大厂,18年进入阿里一直到现在。
深知大多数初中级前端工程师,想要提升技能,往往是自己摸索成长或者是报班学习,但自己不成体系的自学效果低效又漫长,而且极易碰到天花板技术停滞不前!
因此收集整理了一份《2024年Web前端开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注:前端)
最后
面试一面会问很多基础问题,而这些基础问题基本上在网上搜索,面试题都会很多很多。最好把准备一下常见的面试问题,毕竟面试也相当与一次考试,所以找工作面试的准备千万别偷懒。面试就跟考试一样的,时间长了不复习,现场表现肯定不会太好。表现的不好面试官不可能说,我猜他没发挥好,我录用他吧。
开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】
96道前端面试题:
常用算法面试题:
前端基础面试题:
内容主要包括HTML,CSS,JavaScript,浏览器,性能优化
术停滞不前!**
因此收集整理了一份《2024年Web前端开发全套学习资料》送给大家,初衷也很简单,就是希望能够帮助到想自学提升又不知道该从何学起的朋友,同时减轻大家的负担。
[外链图片转存中…(img-OSfuOEW0-1710965362784)]
[外链图片转存中…(img-vbp7DNh8-1710965362785)]
[外链图片转存中…(img-viP11TY0-1710965362785)]
[外链图片转存中…(img-79I9VemP-1710965362786)]
由于文件比较大,这里只是将部分目录截图出来,每个节点里面都包含大厂面经、学习笔记、源码讲义、实战项目、讲解视频
如果你觉得这些内容对你有帮助,可以添加下面V无偿领取!(备注:前端)
[外链图片转存中…(img-FZIlp8Wh-1710965362786)]
最后
面试一面会问很多基础问题,而这些基础问题基本上在网上搜索,面试题都会很多很多。最好把准备一下常见的面试问题,毕竟面试也相当与一次考试,所以找工作面试的准备千万别偷懒。面试就跟考试一样的,时间长了不复习,现场表现肯定不会太好。表现的不好面试官不可能说,我猜他没发挥好,我录用他吧。
开源分享:【大厂前端面试题解析+核心总结学习笔记+真实项目实战+最新讲解视频】
96道前端面试题:
- [外链图片转存中…(img-lyrjZpdg-1710965362787)]
常用算法面试题:
- [外链图片转存中…(img-uMxy1HHh-1710965362787)]
前端基础面试题:
内容主要包括HTML,CSS,JavaScript,浏览器,性能优化