——————————DescriptionStart——————————
运行环境
Java≥8、MySQL≥5.7、Tomcat≥8
开发工具
eclipse/idea/myeclipse/sts等均可配置运行
适用
课程设计,大作业,毕业设计,项目练习,学习演示等
功能说明





基于javaweb的JSP+Servlet网上书城+后台管理系统(java+jsp+servlert+mysql+ajax)
1 2 3 4 5 6 7
| 前台:http://localhost:8080 user1 123456 user2 123456 user3 123456
后台:http://localhost:8080/goods/admin admin 123456
|
一、项目简述
功能: 前台: * 用户模块 * 分类模块 * 图书模块 * 购物车模块 * 订单模块
后台: * 管理员模块 * 分类管理模块 * 图书管理模块 * 订单模块
二、项目运行
环境配置: Jdk1.8 + Tomcat8.5 + mysql + Eclispe (IntelliJ IDEA,Eclispe,MyEclispe,Sts 都支持)
项目技术: JSP + C3P0+ Servlert + html+ css + JavaScript + JQuery + Ajax + Fileupload等等。
——————————CodeStart——————————
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38
|
public class AdminAddBookServlet extends HttpServlet { public void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { request.setCharacterEncoding("utf-8"); response.setContentType("text/html;charset=utf-8");
FileItemFactory factory = new DiskFileItemFactory();
ServletFileUpload sfu = new ServletFileUpload(factory); sfu.setFileSizeMax(80 * 1024);
List<FileItem> fileItemList = null; try { fileItemList = sfu.parseRequest(request); } catch (FileUploadException e) { error("上传的文件超出了80KB", request, response); return; }
Map<String,Object> map = new HashMap<String,Object>(); for(FileItem fileItem : fileItemList) { if(fileItem.isFormField()) { map.put(fileItem.getFieldName(), fileItem.getString("UTF-8"));
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| */ PageBean<Order> pb = orderService.myOrders(user.getUid(), pc);
pb.setUrl(url); req.setAttribute("pb", pb); return "f:/jsps/order/list.jsp"; } } package cn.itcast.goods.user.web.servlet;
public class UserServlet extends BaseServlet { private UserService userService = new UserService();
public String ajaxValidateLoginname(HttpServletRequest req, HttpServletResponse resp)
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
| String url = getUrl(req);
String press = req.getParameter("press");
PageBean<Book> pb = bookService.findByPress(press, pc);
pb.setUrl(url); req.setAttribute("pb", pb); return "f:/jsps/book/list.jsp"; }
public String findByBname(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
int pc = getPc(req);
String url = getUrl(req);
String bname = req.getParameter("bname");
PageBean<Book> pb = bookService.findByBname(bname, pc);
pb.setUrl(url);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
String url = getUrl(req);
String bname = req.getParameter("bname");
PageBean<Book> pb = bookService.findByBname(bname, pc);
pb.setUrl(url); req.setAttribute("pb", pb); return "f:/jsps/book/list.jsp"; }
public String findByCombination(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
int pc = getPc(req);
String url = getUrl(req);
Book criteria = CommonUtils.toBean(req.getParameterMap(), Book.class);
PageBean<Book> pb = bookService.findByCombination(criteria, pc);
pb.setUrl(url); req.setAttribute("pb", pb);
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
| * @throws IOException */ public String load(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String bid = req.getParameter("bid"); Book book = bookService.load(bid); req.setAttribute("book", book); return "f:/jsps/book/desc.jsp"; }
public String findByCategory(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
int pc = getPc(req);
String url = getUrl(req);
String cid = req.getParameter("cid");
PageBean<Book> pb = bookService.findByCategory(cid, pc);
pb.setUrl(url); req.setAttribute("pb", pb); return "f:/jsps/book/list.jsp"; }
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36
| * @param req * @param resp * @return * @throws ServletException * @throws IOException */ public String findByCombination(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
int pc = getPc(req);
String url = getUrl(req);
Book criteria = CommonUtils.toBean(req.getParameterMap(), Book.class);
PageBean<Book> pb = bookService.findByCombination(criteria, pc);
pb.setUrl(url); req.setAttribute("pb", pb); return "f:/jsps/book/list.jsp"; } } package cn.itcast.goods.admin.web.servlet;
|
——————————PayStart——————————
项目链接:
https://javayms.github.io?id=241422292105200ex
https://javayms.pages.dev?id=241422292105200ex