您好,登錄后才能下訂單哦!
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進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。