作者主页:编程指南针

简介:Java领域优质创作者、CSDN博客专家  Java项目、简历模板、学习资料、面试题库、技术互助

文末获取源码

项目编号:BS-SC-001

本项目基于JSP+SERVLET+Durid连接池进行开发实现,数据库采用MYSQL数据库,开发工具为IDEA或ECLIPSE,前端用采用BootStrap开发实现。系统采用三层架构设计,MVC设计模式。系统功能完整,页面简洁大方,维护方便,适合做毕业设计使用。

具体系统功能展示如下:

前台页面功能:

分类显示

餐品详情

添加购物车

个人订单管理

个人资料修改

系统留言

最近浏览功能

后台管理功能:

管理员登陆:  admin / admin

用户管理

分类管理

餐品管理

订单管理

留言管理

新闻管理

本系统是一款优秀的毕业设计系统,完美的实现了基于餐饮业务的网上订餐流程,功能强大,运行稳定,结构清晰,便于修改,适合做毕业设计使用。

部分核心代码:

package cn.jbit.easybuy.web;import java.io.IOException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;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 cn.jbit.easybuy.biz.FacilityService;
import cn.jbit.easybuy.biz.OrderService;
import cn.jbit.easybuy.biz.ProductService;
import cn.jbit.easybuy.biz.impl.FacilityServiceImpl;
import cn.jbit.easybuy.biz.impl.OrderServiceImpl;
import cn.jbit.easybuy.biz.impl.ProductServiceImpl;
import cn.jbit.easybuy.entity.News;
import cn.jbit.easybuy.entity.Pager;
import cn.jbit.easybuy.entity.Product;
import cn.jbit.easybuy.entity.ProductCategory;
import cn.jbit.easybuy.entity.ShoppingCart;
import cn.jbit.easybuy.entity.User;
import cn.jbit.easybuy.util.ActionResult;
import cn.jbit.easybuy.util.Validator;public class CartServlet extends HttpServlet {protected Map<String, ActionResult> viewMapping = new HashMap<String, ActionResult>();private ProductService productService;private FacilityService facilityService;private OrderService orderService;public void init() throws ServletException {productService = new ProductServiceImpl();facilityService = new FacilityServiceImpl();orderService = new OrderServiceImpl();}protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {doPost(req, resp);}protected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {req.setCharacterEncoding("utf-8");createViewMapping();String actionIndicator = req.getParameter("action");String result = "";if (actionIndicator == null)actionIndicator = "list";if ("list".endsWith(actionIndicator)) {result = list(req);} else if ("add".endsWith(actionIndicator)) {result = add(req);} else if ("mod".endsWith(actionIndicator)) {result = mod(req);} else if ("remove".endsWith(actionIndicator)) {result = remove(req);} else if ("pay".endsWith(actionIndicator)) {result = pay(req);}toView(req, resp, result);}private String pay(HttpServletRequest request) {ShoppingCart cart = getCartFromSession(request);User user = getUserFromSession(request);if(user==null)return "login";orderService.payShoppingCart(cart, user);removeCartFromSession(request);return "paySuccess";}private void removeCartFromSession(HttpServletRequest request) {request.getSession().removeAttribute("cart");}private User getUserFromSession(HttpServletRequest request) {HttpSession session = request.getSession();return (User) session.getAttribute("loginUser");}private String add(HttpServletRequest request) {String id = request.getParameter("entityId");String quantityStr = request.getParameter("quantity");long quantity = 1;if (!Validator.isEmpty(quantityStr))quantity = Long.parseLong(quantityStr);Product product = productService.findById(id);ShoppingCart cart = getCartFromSession(request);cart.addItem(product, quantity);return "addSuccess";}private String mod(HttpServletRequest request) {String id = request.getParameter("entityId");String quantityStr = request.getParameter("quantity");long quantity = 1;if (!Validator.isEmpty(quantityStr))quantity = Long.parseLong(quantityStr);String indexStr = request.getParameter("index");ShoppingCart cart = getCartFromSession(request);cart.modifyQuantity(Integer.parseInt(indexStr), quantity);return "modSuccess";}private String remove(HttpServletRequest request) {String id = request.getParameter("entityId");String quantityStr = request.getParameter("quantity");long quantity = 1;if (!Validator.isEmpty(quantityStr))quantity = Long.parseLong(quantityStr);String indexStr = request.getParameter("index");ShoppingCart cart = getCartFromSession(request);cart.getItems().remove(Integer.parseInt(indexStr));return "removeSuccess";}private ShoppingCart getCartFromSession(HttpServletRequest request) {HttpSession session = request.getSession();ShoppingCart cart = (ShoppingCart) session.getAttribute("cart");if (cart == null) {cart = new ShoppingCart();session.setAttribute("cart", cart);}//取出当前用户的订单列表return cart;}private String list(HttpServletRequest request) {getCartFromSession(request);return "listSuccess";}private void prepareCategories(HttpServletRequest request) {List<ProductCategory> categories = productService.getProductCategories(null);request.setAttribute("categories", categories);}private void prepareNews(HttpServletRequest request) {List<News> allNews = facilityService.getAllNews(new Pager(10, 1));request.setAttribute("allNews", allNews);}protected void createViewMapping() {this.addMapping("listSuccess", "shopping.jsp");this.addMapping("paySuccess", "shopping-result.jsp");this.addMapping("addSuccess", "Cart", true);this.addMapping("removeSuccess", "Cart", true);this.addMapping("modSuccess", "Cart", true);this.addMapping("login", "login.jsp");}private void toView(HttpServletRequest req, HttpServletResponse resp,String result) throws IOException, ServletException {ActionResult dest = this.viewMapping.get(result);if (dest.isRedirect()) {resp.sendRedirect(dest.getViewName());} else {req.getRequestDispatcher(dest.getViewName()).forward(req, resp);}}protected void addMapping(String viewName, String url) {this.viewMapping.put(viewName, new ActionResult(url));}protected void addMapping(String viewName, String url, boolean isDirect) {this.viewMapping.put(viewName, new ActionResult(url, isDirect));}
}
package cn.jbit.easybuy.web;import java.io.IOException;
import java.util.List;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import cn.jbit.easybuy.biz.ProductService;
import cn.jbit.easybuy.biz.impl.ProductServiceImpl;
import cn.jbit.easybuy.entity.ProductCategory;
import cn.jbit.easybuy.util.ActionResult;
import cn.jbit.easybuy.util.Validator;public class CategoryServlet extends HttpServlet {private ProductService productService;public void init() throws ServletException {productService = new ProductServiceImpl();}protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {doPost(req, resp);}protected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {req.setCharacterEncoding("utf-8");String actionIndicator = req.getParameter("action");ActionResult result = new ActionResult("error");Validator validator = new Validator(Validator.toSingleParameters(req));if (actionIndicator == null)actionIndicator = "list";if ("read".endsWith(actionIndicator)) {result = read(req, validator);} else if ("list".endsWith(actionIndicator)) {result = list(req, validator);} else if ("create".endsWith(actionIndicator)) {result = create(req, validator);} else if ("delete".endsWith(actionIndicator)) {result = delete(req, validator);} else if ("save".endsWith(actionIndicator)) {boolean isEdit = true;String editIndicator = req.getParameter("entityId");if (Validator.isEmpty(editIndicator))isEdit = false;result = save(req, validator, isEdit);}if (!validator.hasErrors() && result.isRedirect()) {resp.sendRedirect(result.getViewName());} else {req.setAttribute("errors", validator.getErrors());req.getRequestDispatcher(result.getViewName()).forward(req, resp);}}public ActionResult read(HttpServletRequest request, Validator validator) {ProductCategory category = productService.findCategoryById(request.getParameter("entityId"));pupulateRequest(request, category);List<ProductCategory> categories = productService.getRootCategories();request.setAttribute("categories", categories);return new ActionResult("productClass-modify.jsp");}public ActionResult save(HttpServletRequest request, Validator validator,boolean isEdit) {String entityId = request.getParameter("entityId");checkInputErrors(request, validator);saveToDatabase(request, validator, isEdit);return new ActionResult("Category", true);}public ActionResult create(HttpServletRequest request, Validator validator) {List<ProductCategory> categories = productService.getRootCategories();request.setAttribute("categories", categories);request.setAttribute("parentId", 0);return new ActionResult("productClass-modify.jsp");}public ActionResult delete(HttpServletRequest request, Validator validator) {productService.deleteCategory(request.getParameter("entityId"));return new ActionResult("Category", true);}public ActionResult list(HttpServletRequest request, Validator validator) {List<ProductCategory> categories = productService.getProductCategories(null);request.setAttribute("categories", categories);return new ActionResult("productClass.jsp");}private void saveToDatabase(HttpServletRequest request,Validator validator, boolean isEdit) {if (!validator.hasErrors()) {ProductCategory productCategory;if (!isEdit) {productCategory = new ProductCategory();populateEntity(request, productCategory);productCategory.setParentId(Long.parseLong(request.getParameter("parentId")));productService.saveCategory(productCategory);} else {productCategory = productService.findCategoryById(request.getParameter("entityId"));Long parentId = Long.parseLong(request.getParameter("parentId"));populateEntity(request, productCategory);if (parentId == 0) {if (productCategory.getId().equals(productCategory.getParentId())) {// 说明是一级分类,父分类不能修改,只能改名字productService.updateCategoryName(productCategory);} else {// 二级分类修改为一级分类了,需要额外更新:// Product原先属于该二级分类的,全部更新一级为它,二级为空productCategory.setParentId(productCategory.getId());productService.updateCategory(productCategory,"Level2To1");}} else {if (!parentId.equals(productCategory.getParentId())) {// 二级分类修改了父分类,需要额外更新:// Product原先属于该二级分类的,全部更新一级为新的父分类productCategory.setParentId(parentId);productService.updateCategory(productCategory,"ModifyParent");} else {// 二级分类修改了名字productService.updateCategoryName(productCategory);}}}}}private void pupulateRequest(HttpServletRequest request,ProductCategory productCategory) {request.setAttribute("entityId", Long.toString(productCategory.getId()));request.setAttribute("name", productCategory.getName());request.setAttribute("parentId", (productCategory.getParentId().equals(productCategory.getId())) ? 0 : productCategory.getParentId());}private void checkInputErrors(HttpServletRequest request,Validator validator) {validator.checkRequiredError(new String[] { "name" });}private void populateEntity(HttpServletRequest request,ProductCategory productCategory) {productCategory.setName(request.getParameter("name"));}
}
package cn.jbit.easybuy.web;import java.io.IOException;
import java.util.Date;
import java.util.List;import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;import cn.jbit.easybuy.biz.FacilityService;
import cn.jbit.easybuy.biz.ProductService;
import cn.jbit.easybuy.biz.impl.FacilityServiceImpl;
import cn.jbit.easybuy.biz.impl.ProductServiceImpl;
import cn.jbit.easybuy.entity.Comment;
import cn.jbit.easybuy.entity.Pager;
import cn.jbit.easybuy.entity.ProductCategory;
import cn.jbit.easybuy.util.ActionResult;
import cn.jbit.easybuy.util.Validator;public class CommentServlet extends HttpServlet {private FacilityService facilityService;private ProductService productService;public void init() throws ServletException {this.facilityService = new FacilityServiceImpl();this.productService = new ProductServiceImpl();}protected void doGet(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {doPost(req, resp);}protected void doPost(HttpServletRequest req, HttpServletResponse resp)throws ServletException, IOException {req.setCharacterEncoding("utf-8");String actionIndicator = req.getParameter("action");ActionResult result = new ActionResult("error");Validator validator = new Validator(Validator.toSingleParameters(req));if (actionIndicator == null)actionIndicator = "list";if ("read".endsWith(actionIndicator)) {result = read(req, validator);} else if ("list".endsWith(actionIndicator)) {result = list(req, validator);} else if ("delete".endsWith(actionIndicator)) {result = delete(req, validator);} else if ("save".endsWith(actionIndicator)) {boolean isEdit = true;String editIndicator = req.getParameter("entityId");if (Validator.isEmpty(editIndicator))isEdit = false;result = save(req, validator, isEdit);}if (!validator.hasErrors() && result.isRedirect()) {resp.sendRedirect(result.getViewName());} else {req.setAttribute("errors", validator.getErrors());req.getRequestDispatcher(result.getViewName()).forward(req, resp);}}public ActionResult read(HttpServletRequest request, Validator validator) {Comment comment = facilityService.findCommentById(request.getParameter("entityId"));pupulateRequest(request, comment);return new ActionResult("guestbook-modify.jsp");}public ActionResult save(HttpServletRequest request, Validator validator,boolean isEdit) {checkInputErrors(request, validator);saveToDatabase(request, validator, isEdit);return new ActionResult("GuestBook", true);}public ActionResult delete(HttpServletRequest request, Validator validator) {facilityService.deleteComment(request.getParameter("entityId"));return new ActionResult("GuestBook", true);}public ActionResult list(HttpServletRequest request, Validator validator) {String page = request.getParameter("page");int pageNo = 1;if (!Validator.isEmpty(page))pageNo = Integer.parseInt(page);long rowCount = facilityService.getCommentRowCount();Pager pager = new Pager(rowCount, pageNo);List<Comment> comments = facilityService.getComments(pager);List<ProductCategory> categories = productService.getProductCategories(null);request.setAttribute("categories", categories);request.setAttribute("comments", comments);request.setAttribute("pager", pager);request.setAttribute("pageNo", pageNo);return new ActionResult("guestbook.jsp");}private void pupulateRequest(HttpServletRequest request, Comment comment) {request.setAttribute("entityId", Long.toString(comment.getId()));request.setAttribute("reply", comment.getReply());request.setAttribute("content", comment.getContent());request.setAttribute("nickName", comment.getNickName());request.setAttribute("replayTime", Validator.dateToString(comment.getReplyTime()));}private void saveToDatabase(HttpServletRequest request,Validator validator, boolean isEdit) {if (!validator.hasErrors()) {Comment comment;if (!isEdit) {comment = new Comment();comment.setCreateTime(new Date());populateEntity(request, comment);facilityService.saveComment(comment);} else {comment = facilityService.findCommentById(request.getParameter("entityId"));if (!Validator.isEmpty(request.getParameter("reply"))) {comment.setReply(request.getParameter("reply"));comment.setReplyTime(new Date());}facilityService.updateComment(comment);}}}private void checkInputErrors(HttpServletRequest request,Validator validator) {validator.checkRequiredError(new String[] { "content", "nickName" });}private void populateEntity(HttpServletRequest request, Comment comment) {comment.setContent(request.getParameter("content"));comment.setNickName(request.getParameter("nickName"));}
}

Java项目:基于Jsp实现网上定餐系统相关推荐

  1. Jsp实现网上定餐系统

    项目编号:BS-SC-001 本项目基于JSP+SERVLET+Durid连接池进行开发实现,数据库采用MYSQL数据库,开发工具为IDEA或ECLIPSE,前端用采用BootStrap开发实现.系统 ...

  2. 基于Java的电子作业提交系统_基于jsp的网上作业提交系统-JavaEE实现网上作业提交系统 - java项目源码...

    基于jsp+servlet+pojo+mysql实现一个javaee/javaweb的网上作业提交系统, 该项目可用各类java课程设计大作业中, 网上作业提交系统的系统架构分为前后台两部分, 最终实 ...

  3. Java基于JSP的网上手机销售系统

    手机作为一个通讯工具一直在不断的更新换代,由最初的大哥大,到小灵通,再到诺基亚的塞班系统,直到现在的苹果安卓等系统.手机的功能也越来越多,从最初的只能打电话到现在聊天,游戏和看视频等功能.人们的业余生 ...

  4. [附源码]计算机毕业设计基于springboot的网上点餐系统

    项目运行 环境配置: Jdk1.8 + Tomcat7.0 + Mysql + HBuilderX(Webstorm也行)+ Eclispe(IntelliJ IDEA,Eclispe,MyEclis ...

  5. 基于JSP的网上服装销售系统

    技术:Java.JSP等 摘要: 伴随着Internet的蓬勃发展,网络购物中心作为电子商务的一种形式正以其高校.低成本的优势,逐步成为新兴的经营模式和理念.网上服装销售系统给人们带来了极大的方便,后 ...

  6. 基于JSP的网上演唱会票务系统

    技术:Java.JSP等 摘要: 随着当今社会科技的发展,人们的精神生活水平日益提高.在这高新技术发展的时代,因特网的快速发展,使人们的生活更加便利,让人们的生活丰富多彩.本基于JSP的网上演唱会票务 ...

  7. 基于html的网上点餐系统,一种基于客户端的网上点餐系统的制作方法

    本发明涉及互联网技术领域,具体为一种基于客户端的网上点餐系统. 背景技术: 互联网是网络与网络之间所串连成的庞大网络,这些网络以一组通用的协议相连,形成逻辑上的单一且巨大的全球化网络,在这个网络中有交 ...

  8. DoNet开源项目-基于Amaze UI的点餐系统

    本文转载于 石佳劼的博客,有问题请到原文咨询,原文连接. 点餐系统 帮朋友做的点餐系统,主要是为了让顾客在餐桌上,使用微信扫描二维码,就可以直接点菜,吃完使用微信付款. 系统演示地址,账户名和密码均为 ...

  9. ssm基于jsp的在线点餐系统 毕业设计源码111016

    基于SSM的在线点餐系统 摘要 当前高速发展的经济模式下,人们工作和生活都处于高压下,没时间做饭,在哪做饭成了人们的难题,传统下班回家做饭的生活习俗渐渐地变得难以实现.在社会驱动下,我国在餐饮方面的收 ...

最新文章

  1. Revit:概念建模环境技能学习 Revit: Conceptual Modeling Environment
  2. MyBatis3 xml映射文件配置
  3. 【leetcode】clone-graph
  4. nslookup默认服务器修改,Nslookup命令的使用 - [详细]
  5. .Net(C#)用正则表达式清除HTML标签(包括script和style),保留纯本文(UEdit中编写的内容上传到数据库)...
  6. 前端实现只显示年月日
  7. Linux磁盘管理——df、du、磁盘分区、格式化、挂载、LVM
  8. popwindow setFocusable(false) 不消失与弹出软键盘的冰火不容的矛盾
  9. Map 集合循环、遍历的 四 种方式
  10. SHA-3的获胜者:keccak - 在 3GPP TS 35.231、FIPS 202 和 SP 800-185 中标准化
  11. php fstat,PHP fstat( )用法及代码示例
  12. 数据标注——VoTT的学习笔记
  13. 《Python数据分析实战》3 NumPy库
  14. 物联网概论(IoT)_Chp5 物联网通信 Zigbee/蓝牙/UWB/WLAN/WiMax
  15. 红米note9pro刷鸿蒙,红米Note9Pro稳定版刷机包(官方系统固件升级包MIUI11)
  16. php企业微信回调url校验失败,企业微信第三方服务商回调URL无法通过验证
  17. 深入理解GlusterFS之数据均衡
  18. 一位中科院自动化研究所博士毕业论文的致谢
  19. 十万部冷知识:“沙特”为什么能赢“阿根廷”
  20. Chrome浏览器无法启动,因为应用程序的并行配置不正确

热门文章

  1. 有重叠与无重叠序列之序列检测与序列产生
  2. kubenetes kubectl命令记录
  3. 批量下载的实现及java.lang.IllegalStateException异常
  4. [转]Eclipse中的Web项目自动部署到Tomcat
  5. Winforms-GePlugin-Control-library
  6. 图像处理之基础---高斯低通滤波在指定区域画放大圆形图
  7. nagios总结与基本配置模板-V2
  8. 利用openssh实现chroot监牢
  9. 3.4.1 流量控制与可靠传输机制
  10. C++实现各种排序算法