Modul Fungsi Pengguna: Pendaftaran Pengguna: Modul Produk: Modul Pengurusan Bahagian Belakang Fungsi: Modul Pentadbir: Modul Pengurusan Pesanan; 2. Operasi projek
JDK1.8+Tomcat8.5+MYSQL+Eclispe (Eclispe, MyEclispe, Sts, IntelliJ IDEA semuanya disokong, anda boleh mengkonfigurasinya sendiri Ya )
2. Timbunan teknologi
JSP + Servlet + JDBC + Ajax + JavaScript + CSS + +DBUtil dll.
3 >
4. Kod Teras
Lapisan Kawalan Pengurusan Pengguna
public class UserServlet extends BaseBackServlet { @Override public String add(HttpServletRequest request, HttpServletResponse response, Page page) { System.out.println("调用了 UserServlet add方法"); return null; } @Override public String delete(HttpServletRequest request, HttpServletResponse response, Page page) { System.out.println("调用了 UserServlet delete方法"); int id = Integer.parseInt(request.getParameter("id")); userDAO.delete(id); return "@admin_user_list"; } @Override public String update(HttpServletRequest request, HttpServletResponse response, Page page) { System.out.println("调用了 UserServlet update方法"); Map<String, String> params = new HashMap<>(); InputStream is = super.parseUpload(request, params); System.out.println(params); int id = Integer.parseInt(params.get("id")); String password = params.get("password"); User user = userDAO.get(id); user.setPassword(password); userDAO.update(user); return "@admin_user_list"; } @Override public String edit(HttpServletRequest request, HttpServletResponse response, Page page) { System.out.println("调用了 UserServlet edit方法"); int id = Integer.parseInt(request.getParameter("id")); User u = userDAO.get(id); request.setAttribute("u", u); return "admin/editUser.jsp"; } @Override public String list(HttpServletRequest request, HttpServletResponse response, Page page) { System.out.println("调用了 UserServlet list方法"); List<User> us = userDAO.list(page.getStart(), page.getCount()); int total = userDAO.getTotal(); page.setTotal(total); request.setAttribute("us", us); request.setAttribute("page", page); return "admin/listUser.jsp"; } }
public class OrderServlet extends BaseBackServlet { @Override public String add(HttpServletRequest request, HttpServletResponse response, Page page) { return null; } @Override public String delete(HttpServletRequest request, HttpServletResponse response, Page page) { return null; } @Override public String update(HttpServletRequest request, HttpServletResponse response, Page page) { return null; } @Override public String edit(HttpServletRequest request, HttpServletResponse response, Page page) { return null; } public String delivery(HttpServletRequest request, HttpServletResponse response, Page page) { System.out.println("调用了 OrderServlet delivery方法"); int id = Integer.parseInt(request.getParameter("id")); Order o = orderDAO.get(id); o.setDeliveryDate(new Date()); o.setStatus(OrderDAO.waitConfirm); orderDAO.update(o); return "@admin_order_list"; } @Override public String list(HttpServletRequest request, HttpServletResponse response, Page page) { System.out.println("调用了 OrderServlet list方法"); // 对订单对应的订单项进行初始化 List<Order> os = orderDAO.list(page.getStart(), page.getCount()); orderItemDAO.fill(os); int total = orderDAO.getTotal(); page.setTotal(total); request.setAttribute("os", os); request.setAttribute("page", page); return "admin/listOrder.jsp"; } }
Atas ialah kandungan terperinci Bagaimana untuk melaksanakan sistem pusat beli-belah dalam talian pembesar suara Little Bee di Jawa. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!