Java如何进行在线蛋糕销售商城的实现,相信很多没有经验的人对此束手无策,为此本文总结了问题出现的原因和解决方法,通过这篇文章希望你能解决这个问题。
功能: 主页显示商品; 所有蛋糕商品展示,可进行商品搜索; 点击商品进入商品详情页,具有立即购买功能,可增减购买商品数量亦可手动输入,热销商品展示。 立即购买进入确认订单页面,可选择已经添加的地址,亦可新增地址。 可选择购买哪些商品,可删除不需要的商品。 点击结算进入确认订单页面,确认后提交订单。后台管理:(修改密码等),商品管理(商品批量添加、上下架等),订单管理。
Jdk1.8 + Tomcat8.5 + mysql + Eclispe(IntelliJ IDEA,Eclispe,MyEclispe,Sts都支持)
JSP +Springboot+ SpringMVC + MyBatis + ThymeLeaf + FTP+ JavaScript + JQuery + Ajax + maven等等
登录控制层:
@WebServlet(name = "user_login",urlPatterns = "/user_login") public class UserLoginServlet extends HttpServlet { private UserService uService = new UserService(); protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String ue = request.getParameter("ue"); String password = request.getParameter("password"); User user = uService.login(ue, password); if(user==null) { request.setAttribute("failMsg", "用户名、邮箱或者密码错误,请重新登录!"); request.getRequestDispatcher("/user_login.jsp").forward(request, response); }else { request.getSession().setAttribute("user", user); request.getRequestDispatcher("/user_center.jsp").forward(request, response); } } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } }
商品信息列表:
@WebServlet(name = "goods_List",urlPatterns = "/goods_list") public class GoodsListServlet extends HttpServlet { private GoodsService gService=new GoodsService(); private TypeService tService=new TypeService(); protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { } protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int id=0; if(request.getParameter("typeid")!=null) { id=Integer.parseInt(request.getParameter("typeid")); } int pageNumber=1; if(request.getParameter("pageNumber")!=null) { try { pageNumber=Integer.parseInt(request.getParameter("pageNumber")); } catch (Exception e) { } } Type t=null; if(id!=0) { t=tService.selectTypeNameByID(id); } request.setAttribute("t",t); //List<Goods> list=gService.selectGoodsByTypeID(id,1,8); //request.setAttribute("goodsList",list); if(pageNumber<=0) pageNumber=1; Page p=gService.selectPageByTypeID(id,pageNumber); if(p.getTotalPage()==0) { p.setTotalPage(1); p.setPageNumber(1); } else { if(pageNumber>=p.getTotalPage()+1) { p=gService.selectPageByTypeID(id,p.getTotalPage()); } } request.setAttribute("p",p); request.setAttribute("id",String.valueOf(id)); request.getRequestDispatcher("/goods_list.jsp").forward(request,response); } }
管理员订单服务类:
@WebServlet(name = "admin_order_list",urlPatterns = "/admin/order_list") public class AdminOrderListServlet extends HttpServlet { private OrderService oService = new OrderService(); /** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { int status = 0; if(request.getParameter("status") != null) { status=Integer.parseInt(request.getParameter("status") ) ; } request.setAttribute("status", status); int pageNumber = 1; if(request.getParameter("pageNumber") != null) { try { pageNumber=Integer.parseInt(request.getParameter("pageNumber") ) ; } catch (Exception e) { } } if(pageNumber<=0) pageNumber=1; Page p = oService.getOrderPage(status,pageNumber); if(p.getTotalPage()==0) { p.setTotalPage(1); p.setPageNumber(1); } else { if(pageNumber>=p.getTotalPage()+1) { p = oService.getOrderPage(status,pageNumber); } } request.setAttribute("p", p); request.getRequestDispatcher("/admin/order_list.jsp").forward(request, response); } }
Java主要应用于:1. web开发;2. Android开发;3. 客户端开发;4. 网页开发;5. 企业级应用开发;6. Java大数据开发;7.游戏开发等。
看完上述内容,你们掌握Java如何进行在线蛋糕销售商城的实现的方法了吗?如果还想学到更多技能或想了解更多相关内容,欢迎关注亿速云行业资讯频道,感谢各位的阅读!
免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。