how2j.cn

-->
下载区
文件名 文件大小
请先登录 5m
增值内容 5m
5m

解压rar如果失败,请用5.21版本或者更高版本的winrar

点击下载 winrar5.21
步骤 1 : 先运行,看到效果,再学习   
步骤 2 : 模仿和排错   
步骤 3 : 我的订单页面操作   
步骤 4 : 付款   
步骤 5 : 确认收货   
步骤 6 : 确认收货成功   
步骤 7 : 评价   
步骤 8 : 删除   

步骤 1 :

先运行,看到效果,再学习

edit
增值内容,请先登录
完整的J2EE模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE一整套技术栈, 从无到有涵盖全部147个知识点,475个开发步骤, 充实J2EE项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的J2EE模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE一整套技术栈, 从无到有涵盖全部147个知识点,475个开发步骤, 充实J2EE项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
步骤 3 :

我的订单页面操作

edit
增值内容,请先登录
完整的J2EE模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE一整套技术栈, 从无到有涵盖全部147个知识点,475个开发步骤, 充实J2EE项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
我的订单页面操作
增值内容,请先登录
完整的J2EE模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE一整套技术栈, 从无到有涵盖全部147个知识点,475个开发步骤, 充实J2EE项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
付款
增值内容,请先登录
完整的J2EE模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE一整套技术栈, 从无到有涵盖全部147个知识点,475个开发步骤, 充实J2EE项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
确认收货
public String confirmPay(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); orderItemDAO.fill(o); request.setAttribute("o", o); return "confirmPay.jsp"; }
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%> <%@include file="include/header.jsp"%> <%@include file="include/top.jsp"%> <%@include file="include/simpleSearch.jsp"%> <%@include file="include/cart/confirmPayPage.jsp"%> <%@include file="include/footer.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%> <div class="confirmPayPageDiv"> <div class="confirmPayImageDiv"> <img src="img/site/comformPayFlow.png"> <div class="confirmPayTime1"> <fmt:formatDate value="${o.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/> </div> <div class="confirmPayTime2"> <fmt:formatDate value="${o.payDate}" pattern="yyyy-MM-dd HH:mm:ss"/> </div> <div class="confirmPayTime3"> yyyy-MM-dd HH:mm:ss </div> </div> <div class="confirmPayOrderInfoDiv"> <div class="confirmPayOrderInfoText">我已收到货,同意支付宝付款</div> </div> <div class="confirmPayOrderItemDiv"> <div class="confirmPayOrderItemText">订单信息</div> <table class="confirmPayOrderItemTable"> <thead> <th colspan="2">宝贝</th> <th width="120px">单价</th> <th width="120px">数量</th> <th width="120px">商品总价 </th> <th width="120px">运费</th> </thead> <c:forEach items="${o.orderItems}" var="oi"> <tr> <td><img width="50px" src="img/productSingle_middle/${oi.product.firstProductImage.id}.jpg"></td> <td class="confirmPayOrderItemProductLink"> <a href="#nowhere">${oi.product.name}</a> </td> <td>¥<fmt:formatNumber type="number" value="${oi.product.orignalPrice}" minFractionDigits="2"/></td> <td>1</td> <td><span class="conformPayProductPrice">¥<fmt:formatNumber type="number" value="${oi.product.promotePrice}" minFractionDigits="2"/></span></td> <td><span>快递 : 0.00 </span></td> </tr> </c:forEach> </table> <div class="confirmPayOrderItemText pull-right"> 实付款: <span class="confirmPayOrderItemSumPrice">¥<fmt:formatNumber type="number" value="${o.total}" minFractionDigits="2"/></span> </div> </div> <div class="confirmPayOrderDetailDiv"> <table class="confirmPayOrderDetailTable"> <tr> <td>订单编号:</td> <td>${o.orderCode} <img width="23px" src="img/site/confirmOrderTmall.png"></td> </tr> <tr> <td>卖家昵称:</td> <td>天猫商铺 <span class="confirmPayOrderDetailWangWangGif"></span></td> </tr> <tr> <td>收货信息: </td> <td>${o.address},${o.receiver}, ${o.mobile},${o.post} </td> </tr> <tr> <td>成交时间:</td> <td><fmt:formatDate value="${o.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td> </tr> </table> </div> <div class="confirmPayButtonDiv"> <div class="confirmPayWarning">请收到货后,再确认收货!否则您可能钱货两空!</div> <a href="foreorderConfirmed?oid=${o.id}"><button class="confirmPayButton">确认支付</button></a> </div> </div>
package tmall.servlet; import java.io.BufferedWriter; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.math.RandomUtils; import org.springframework.web.util.HtmlUtils; import tmall.bean.Category; import tmall.bean.Order; import tmall.bean.OrderItem; import tmall.bean.Product; import tmall.bean.ProductImage; import tmall.bean.PropertyValue; import tmall.bean.Review; import tmall.bean.User; import tmall.comparator.ProductAllComparator; import tmall.comparator.ProductDateComparator; import tmall.comparator.ProductPriceComparator; import tmall.comparator.ProductReviewComparator; import tmall.comparator.ProductSaleCountComparator; import tmall.dao.CategoryDAO; import tmall.dao.OrderDAO; import tmall.dao.ProductDAO; import tmall.dao.ProductImageDAO; import tmall.util.Page; public class ForeServlet extends BaseForeServlet { public String home(HttpServletRequest request, HttpServletResponse response, Page page) { List<Category> cs= new CategoryDAO().list(); new ProductDAO().fill(cs); new ProductDAO().fillByRow(cs); request.setAttribute("cs", cs); return "home.jsp"; } public String register(HttpServletRequest request, HttpServletResponse response, Page page) { String name = request.getParameter("name"); String password = request.getParameter("password"); name = HtmlUtils.htmlEscape(name); System.out.println(name); boolean exist = userDAO.isExist(name); if(exist){ request.setAttribute("msg", "用户名已经被使用,不能使用"); return "register.jsp"; } User user = new User(); user.setName(name); user.setPassword(password); System.out.println(user.getName()); System.out.println(user.getPassword()); userDAO.add(user); return "@registerSuccess.jsp"; } public String login(HttpServletRequest request, HttpServletResponse response, Page page) { String name = request.getParameter("name"); name = HtmlUtils.htmlEscape(name); String password = request.getParameter("password"); User user = userDAO.get(name,password); if(null==user){ request.setAttribute("msg", "账号密码错误"); return "login.jsp"; } request.getSession().setAttribute("user", user); return "@forehome"; } public String product(HttpServletRequest request, HttpServletResponse response, Page page) { int pid = Integer.parseInt(request.getParameter("pid")); Product p = productDAO.get(pid); List<ProductImage> productSingleImages = productImageDAO.list(p, ProductImageDAO.type_single); List<ProductImage> productDetailImages = productImageDAO.list(p, ProductImageDAO.type_detail); p.setProductSingleImages(productSingleImages); p.setProductDetailImages(productDetailImages); List<PropertyValue> pvs = propertyValueDAO.list(p.getId()); List<Review> reviews = reviewDAO.list(p.getId()); productDAO.setSaleAndReviewNumber(p); request.setAttribute("reviews", reviews); request.setAttribute("p", p); request.setAttribute("pvs", pvs); return "product.jsp"; } public String logout(HttpServletRequest request, HttpServletResponse response, Page page) { request.getSession().removeAttribute("user"); return "@forehome"; } public String checkLogin(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); if(null!=user) return "%success"; return "%fail"; } public String loginAjax(HttpServletRequest request, HttpServletResponse response, Page page) { String name = request.getParameter("name"); String password = request.getParameter("password"); User user = userDAO.get(name,password); if(null==user){ return "%fail"; } request.getSession().setAttribute("user", user); return "%success"; } public String category(HttpServletRequest request, HttpServletResponse response, Page page) { int cid = Integer.parseInt(request.getParameter("cid")); Category c = new CategoryDAO().get(cid); new ProductDAO().fill(c); new ProductDAO().setSaleAndReviewNumber(c.getProducts()); String sort = request.getParameter("sort"); if(null!=sort){ switch(sort){ case "review": Collections.sort(c.getProducts(),new ProductReviewComparator()); break; case "date" : Collections.sort(c.getProducts(),new ProductDateComparator()); break; case "saleCount" : Collections.sort(c.getProducts(),new ProductSaleCountComparator()); break; case "price": Collections.sort(c.getProducts(),new ProductPriceComparator()); break; case "all": Collections.sort(c.getProducts(),new ProductAllComparator()); break; } } request.setAttribute("c", c); return "category.jsp"; } public String search(HttpServletRequest request, HttpServletResponse response, Page page){ String keyword = request.getParameter("keyword"); List<Product> ps= new ProductDAO().search(keyword,0,20); productDAO.setSaleAndReviewNumber(ps); request.setAttribute("ps",ps); return "searchResult.jsp"; } public String buyone(HttpServletRequest request, HttpServletResponse response, Page page) { int pid = Integer.parseInt(request.getParameter("pid")); int num = Integer.parseInt(request.getParameter("num")); Product p = productDAO.get(pid); int oiid = 0; User user =(User) request.getSession().getAttribute("user"); boolean found = false; List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId()==p.getId()){ oi.setNumber(oi.getNumber()+num); orderItemDAO.update(oi); found = true; oiid = oi.getId(); break; } } if(!found){ OrderItem oi = new OrderItem(); oi.setUser(user); oi.setNumber(num); oi.setProduct(p); orderItemDAO.add(oi); oiid = oi.getId(); } return "@forebuy?oiid="+oiid; } public String buy(HttpServletRequest request, HttpServletResponse response, Page page){ String[] oiids=request.getParameterValues("oiid"); List<OrderItem> ois = new ArrayList<>(); float total = 0; for (String strid : oiids) { int oiid = Integer.parseInt(strid); OrderItem oi= orderItemDAO.get(oiid); total +=oi.getProduct().getPromotePrice()*oi.getNumber(); ois.add(oi); } request.getSession().setAttribute("ois", ois); request.setAttribute("total", total); return "buy.jsp"; } public String addCart(HttpServletRequest request, HttpServletResponse response, Page page) { int pid = Integer.parseInt(request.getParameter("pid")); Product p = productDAO.get(pid); int num = Integer.parseInt(request.getParameter("num")); User user =(User) request.getSession().getAttribute("user"); boolean found = false; List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId()==p.getId()){ oi.setNumber(oi.getNumber()+num); orderItemDAO.update(oi); found = true; break; } } if(!found){ OrderItem oi = new OrderItem(); oi.setUser(user); oi.setNumber(num); oi.setProduct(p); orderItemDAO.add(oi); } return "%success"; } public String cart(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); request.setAttribute("ois", ois); return "cart.jsp"; } public String changeOrderItem(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); if(null==user) return "%fail"; int pid = Integer.parseInt(request.getParameter("pid")); int number = Integer.parseInt(request.getParameter("number")); List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId()==pid){ oi.setNumber(number); orderItemDAO.update(oi); break; } } return "%success"; } public String deleteOrderItem(HttpServletRequest request, HttpServletResponse response, Page page){ User user =(User) request.getSession().getAttribute("user"); if(null==user) return "%fail"; int oiid = Integer.parseInt(request.getParameter("oiid")); orderItemDAO.delete(oiid); return "%success"; } public String createOrder(HttpServletRequest request, HttpServletResponse response, Page page){ User user =(User) request.getSession().getAttribute("user"); String address = request.getParameter("address"); String post = request.getParameter("post"); String receiver = request.getParameter("receiver"); String mobile = request.getParameter("mobile"); String userMessage = request.getParameter("userMessage"); String orderCode = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) +RandomUtils.nextInt(10000); Order order = new Order(); order.setOrderCode(orderCode); order.setAddress(address); order.setPost(post); order.setReceiver(receiver); order.setMobile(mobile); order.setUserMessage(userMessage); order.setCreateDate(new Date()); order.setUser(user); order.setStatus(OrderDAO.waitPay); orderDAO.add(order); List<OrderItem> ois= (List<OrderItem>) request.getSession().getAttribute("ois"); float total =0; for (OrderItem oi: ois) { oi.setOrder(order); orderItemDAO.update(oi); total+=oi.getProduct().getPromotePrice()*oi.getNumber(); } return "@forealipay?oid="+order.getId() +"&total="+total; } public String alipay(HttpServletRequest request, HttpServletResponse response, Page page){ return "alipay.jsp"; } public String payed(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order order = orderDAO.get(oid); order.setStatus(OrderDAO.waitDelivery); order.setPayDate(new Date()); new OrderDAO().update(order); request.setAttribute("o", order); return "payed.jsp"; } public String bought(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); List<Order> os= orderDAO.list(user.getId(),OrderDAO.delete); orderItemDAO.fill(os); request.setAttribute("os", os); return "bought.jsp"; } public String confirmPay(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); orderItemDAO.fill(o); request.setAttribute("o", o); return "confirmPay.jsp"; } public String orderconfirmed(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); o.setStatus(OrderDAO.waitReview); o.setConfirmDate(new Date()); orderDAO.update(o); return "orderConfirmed.jsp"; } public String deleteOrder(HttpServletRequest request, HttpServletResponse response, Page page){ User user =(User) request.getSession().getAttribute("user"); if(null==user) return "%fail"; int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); o.setStatus(OrderDAO.delete); orderDAO.update(o); return "%success"; } }
步骤 6 :

确认收货成功

edit
增值内容,请先登录
完整的J2EE模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE一整套技术栈, 从无到有涵盖全部147个知识点,475个开发步骤, 充实J2EE项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
public String orderConfirmed(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); o.setStatus(OrderDAO.waitReview); o.setConfirmDate(new Date()); orderDAO.update(o); return "orderConfirmed.jsp"; }
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%> <%@include file="include/header.jsp"%> <%@include file="include/top.jsp"%> <%@include file="include/simpleSearch.jsp"%> <%@include file="include/cart/orderConfirmedPage.jsp"%> <%@include file="include/footer.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%> <div class="orderFinishDiv"> <div class="orderFinishTextDiv"> <img src="img/site/orderFinish.png"> <span>交易已经成功,卖家将收到您的货款。</span> </div> </div>
package tmall.servlet; import java.io.BufferedWriter; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.math.RandomUtils; import org.springframework.web.util.HtmlUtils; import tmall.bean.Category; import tmall.bean.Order; import tmall.bean.OrderItem; import tmall.bean.Product; import tmall.bean.ProductImage; import tmall.bean.PropertyValue; import tmall.bean.Review; import tmall.bean.User; import tmall.comparator.ProductAllComparator; import tmall.comparator.ProductDateComparator; import tmall.comparator.ProductPriceComparator; import tmall.comparator.ProductReviewComparator; import tmall.comparator.ProductSaleCountComparator; import tmall.dao.CategoryDAO; import tmall.dao.OrderDAO; import tmall.dao.ProductDAO; import tmall.dao.ProductImageDAO; import tmall.util.Page; public class ForeServlet extends BaseForeServlet { public String home(HttpServletRequest request, HttpServletResponse response, Page page) { List<Category> cs= new CategoryDAO().list(); new ProductDAO().fill(cs); new ProductDAO().fillByRow(cs); request.setAttribute("cs", cs); return "home.jsp"; } public String register(HttpServletRequest request, HttpServletResponse response, Page page) { String name = request.getParameter("name"); String password = request.getParameter("password"); name = HtmlUtils.htmlEscape(name); System.out.println(name); boolean exist = userDAO.isExist(name); if(exist){ request.setAttribute("msg", "用户名已经被使用,不能使用"); return "register.jsp"; } User user = new User(); user.setName(name); user.setPassword(password); System.out.println(user.getName()); System.out.println(user.getPassword()); userDAO.add(user); return "@registerSuccess.jsp"; } public String login(HttpServletRequest request, HttpServletResponse response, Page page) { String name = request.getParameter("name"); name = HtmlUtils.htmlEscape(name); String password = request.getParameter("password"); User user = userDAO.get(name,password); if(null==user){ request.setAttribute("msg", "账号密码错误"); return "login.jsp"; } request.getSession().setAttribute("user", user); return "@forehome"; } public String product(HttpServletRequest request, HttpServletResponse response, Page page) { int pid = Integer.parseInt(request.getParameter("pid")); Product p = productDAO.get(pid); List<ProductImage> productSingleImages = productImageDAO.list(p, ProductImageDAO.type_single); List<ProductImage> productDetailImages = productImageDAO.list(p, ProductImageDAO.type_detail); p.setProductSingleImages(productSingleImages); p.setProductDetailImages(productDetailImages); List<PropertyValue> pvs = propertyValueDAO.list(p.getId()); List<Review> reviews = reviewDAO.list(p.getId()); productDAO.setSaleAndReviewNumber(p); request.setAttribute("reviews", reviews); request.setAttribute("p", p); request.setAttribute("pvs", pvs); return "product.jsp"; } public String logout(HttpServletRequest request, HttpServletResponse response, Page page) { request.getSession().removeAttribute("user"); return "@forehome"; } public String checkLogin(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); if(null!=user) return "%success"; return "%fail"; } public String loginAjax(HttpServletRequest request, HttpServletResponse response, Page page) { String name = request.getParameter("name"); String password = request.getParameter("password"); User user = userDAO.get(name,password); if(null==user){ return "%fail"; } request.getSession().setAttribute("user", user); return "%success"; } public String category(HttpServletRequest request, HttpServletResponse response, Page page) { int cid = Integer.parseInt(request.getParameter("cid")); Category c = new CategoryDAO().get(cid); new ProductDAO().fill(c); new ProductDAO().setSaleAndReviewNumber(c.getProducts()); String sort = request.getParameter("sort"); if(null!=sort){ switch(sort){ case "review": Collections.sort(c.getProducts(),new ProductReviewComparator()); break; case "date" : Collections.sort(c.getProducts(),new ProductDateComparator()); break; case "saleCount" : Collections.sort(c.getProducts(),new ProductSaleCountComparator()); break; case "price": Collections.sort(c.getProducts(),new ProductPriceComparator()); break; case "all": Collections.sort(c.getProducts(),new ProductAllComparator()); break; } } request.setAttribute("c", c); return "category.jsp"; } public String search(HttpServletRequest request, HttpServletResponse response, Page page){ String keyword = request.getParameter("keyword"); List<Product> ps= new ProductDAO().search(keyword,0,20); productDAO.setSaleAndReviewNumber(ps); request.setAttribute("ps",ps); return "searchResult.jsp"; } public String buyone(HttpServletRequest request, HttpServletResponse response, Page page) { int pid = Integer.parseInt(request.getParameter("pid")); int num = Integer.parseInt(request.getParameter("num")); Product p = productDAO.get(pid); int oiid = 0; User user =(User) request.getSession().getAttribute("user"); boolean found = false; List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId()==p.getId()){ oi.setNumber(oi.getNumber()+num); orderItemDAO.update(oi); found = true; oiid = oi.getId(); break; } } if(!found){ OrderItem oi = new OrderItem(); oi.setUser(user); oi.setNumber(num); oi.setProduct(p); orderItemDAO.add(oi); oiid = oi.getId(); } return "@forebuy?oiid="+oiid; } public String buy(HttpServletRequest request, HttpServletResponse response, Page page){ String[] oiids=request.getParameterValues("oiid"); List<OrderItem> ois = new ArrayList<>(); float total = 0; for (String strid : oiids) { int oiid = Integer.parseInt(strid); OrderItem oi= orderItemDAO.get(oiid); total +=oi.getProduct().getPromotePrice()*oi.getNumber(); ois.add(oi); } request.getSession().setAttribute("ois", ois); request.setAttribute("total", total); return "buy.jsp"; } public String addCart(HttpServletRequest request, HttpServletResponse response, Page page) { int pid = Integer.parseInt(request.getParameter("pid")); Product p = productDAO.get(pid); int num = Integer.parseInt(request.getParameter("num")); User user =(User) request.getSession().getAttribute("user"); boolean found = false; List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId()==p.getId()){ oi.setNumber(oi.getNumber()+num); orderItemDAO.update(oi); found = true; break; } } if(!found){ OrderItem oi = new OrderItem(); oi.setUser(user); oi.setNumber(num); oi.setProduct(p); orderItemDAO.add(oi); } return "%success"; } public String cart(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); request.setAttribute("ois", ois); return "cart.jsp"; } public String changeOrderItem(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); if(null==user) return "%fail"; int pid = Integer.parseInt(request.getParameter("pid")); int number = Integer.parseInt(request.getParameter("number")); List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId()==pid){ oi.setNumber(number); orderItemDAO.update(oi); break; } } return "%success"; } public String deleteOrderItem(HttpServletRequest request, HttpServletResponse response, Page page){ User user =(User) request.getSession().getAttribute("user"); if(null==user) return "%fail"; int oiid = Integer.parseInt(request.getParameter("oiid")); orderItemDAO.delete(oiid); return "%success"; } public String createOrder(HttpServletRequest request, HttpServletResponse response, Page page){ User user =(User) request.getSession().getAttribute("user"); String address = request.getParameter("address"); String post = request.getParameter("post"); String receiver = request.getParameter("receiver"); String mobile = request.getParameter("mobile"); String userMessage = request.getParameter("userMessage"); String orderCode = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) +RandomUtils.nextInt(10000); Order order = new Order(); order.setOrderCode(orderCode); order.setAddress(address); order.setPost(post); order.setReceiver(receiver); order.setMobile(mobile); order.setUserMessage(userMessage); order.setCreateDate(new Date()); order.setUser(user); order.setStatus(OrderDAO.waitPay); orderDAO.add(order); List<OrderItem> ois= (List<OrderItem>) request.getSession().getAttribute("ois"); float total =0; for (OrderItem oi: ois) { oi.setOrder(order); orderItemDAO.update(oi); total+=oi.getProduct().getPromotePrice()*oi.getNumber(); } return "@forealipay?oid="+order.getId() +"&total="+total; } public String alipay(HttpServletRequest request, HttpServletResponse response, Page page){ return "alipay.jsp"; } public String payed(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order order = orderDAO.get(oid); order.setStatus(OrderDAO.waitDelivery); order.setPayDate(new Date()); new OrderDAO().update(order); request.setAttribute("o", order); return "payed.jsp"; } public String bought(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); List<Order> os= orderDAO.list(user.getId(),OrderDAO.delete); orderItemDAO.fill(os); request.setAttribute("os", os); return "bought.jsp"; } public String confirmPay(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); orderItemDAO.fill(o); request.setAttribute("o", o); return "confirmPay.jsp"; } public String orderConfirmed(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); o.setStatus(OrderDAO.waitReview); o.setConfirmDate(new Date()); orderDAO.update(o); return "orderConfirmed.jsp"; } public String deleteOrder(HttpServletRequest request, HttpServletResponse response, Page page){ User user =(User) request.getSession().getAttribute("user"); if(null==user) return "%fail"; int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); o.setStatus(OrderDAO.delete); orderDAO.update(o); return "%success"; } }
增值内容,请先登录
完整的J2EE模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE一整套技术栈, 从无到有涵盖全部147个知识点,475个开发步骤, 充实J2EE项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的J2EE模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE一整套技术栈, 从无到有涵盖全部147个知识点,475个开发步骤, 充实J2EE项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
删除
var page="foredeleteOrder"; $.post( page, {"oid":deleteOrderid}, function(result){ if("success"==result){ $("table.orderListItemTable[oid="+deleteOrderid+"]").hide(); } else{ location.href="login.jsp"; } } );
public String deleteOrder(HttpServletRequest request, HttpServletResponse response, Page page){ int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); o.setStatus(OrderDAO.delete); orderDAO.update(o); return "%success"; }
package tmall.servlet; import java.io.BufferedWriter; import java.io.PrintWriter; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import org.apache.commons.lang.math.RandomUtils; import org.springframework.web.util.HtmlUtils; import tmall.bean.Category; import tmall.bean.Order; import tmall.bean.OrderItem; import tmall.bean.Product; import tmall.bean.ProductImage; import tmall.bean.PropertyValue; import tmall.bean.Review; import tmall.bean.User; import tmall.comparator.ProductAllComparator; import tmall.comparator.ProductDateComparator; import tmall.comparator.ProductPriceComparator; import tmall.comparator.ProductReviewComparator; import tmall.comparator.ProductSaleCountComparator; import tmall.dao.CategoryDAO; import tmall.dao.OrderDAO; import tmall.dao.ProductDAO; import tmall.dao.ProductImageDAO; import tmall.util.Page; public class ForeServlet extends BaseForeServlet { public String home(HttpServletRequest request, HttpServletResponse response, Page page) { List<Category> cs= new CategoryDAO().list(); new ProductDAO().fill(cs); new ProductDAO().fillByRow(cs); request.setAttribute("cs", cs); return "home.jsp"; } public String register(HttpServletRequest request, HttpServletResponse response, Page page) { String name = request.getParameter("name"); String password = request.getParameter("password"); name = HtmlUtils.htmlEscape(name); System.out.println(name); boolean exist = userDAO.isExist(name); if(exist){ request.setAttribute("msg", "用户名已经被使用,不能使用"); return "register.jsp"; } User user = new User(); user.setName(name); user.setPassword(password); System.out.println(user.getName()); System.out.println(user.getPassword()); userDAO.add(user); return "@registerSuccess.jsp"; } public String login(HttpServletRequest request, HttpServletResponse response, Page page) { String name = request.getParameter("name"); name = HtmlUtils.htmlEscape(name); String password = request.getParameter("password"); User user = userDAO.get(name,password); if(null==user){ request.setAttribute("msg", "账号密码错误"); return "login.jsp"; } request.getSession().setAttribute("user", user); return "@forehome"; } public String product(HttpServletRequest request, HttpServletResponse response, Page page) { int pid = Integer.parseInt(request.getParameter("pid")); Product p = productDAO.get(pid); List<ProductImage> productSingleImages = productImageDAO.list(p, ProductImageDAO.type_single); List<ProductImage> productDetailImages = productImageDAO.list(p, ProductImageDAO.type_detail); p.setProductSingleImages(productSingleImages); p.setProductDetailImages(productDetailImages); List<PropertyValue> pvs = propertyValueDAO.list(p.getId()); List<Review> reviews = reviewDAO.list(p.getId()); productDAO.setSaleAndReviewNumber(p); request.setAttribute("reviews", reviews); request.setAttribute("p", p); request.setAttribute("pvs", pvs); return "product.jsp"; } public String logout(HttpServletRequest request, HttpServletResponse response, Page page) { request.getSession().removeAttribute("user"); return "@forehome"; } public String checkLogin(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); if(null!=user) return "%success"; return "%fail"; } public String loginAjax(HttpServletRequest request, HttpServletResponse response, Page page) { String name = request.getParameter("name"); String password = request.getParameter("password"); User user = userDAO.get(name,password); if(null==user){ return "%fail"; } request.getSession().setAttribute("user", user); return "%success"; } public String category(HttpServletRequest request, HttpServletResponse response, Page page) { int cid = Integer.parseInt(request.getParameter("cid")); Category c = new CategoryDAO().get(cid); new ProductDAO().fill(c); new ProductDAO().setSaleAndReviewNumber(c.getProducts()); String sort = request.getParameter("sort"); if(null!=sort){ switch(sort){ case "review": Collections.sort(c.getProducts(),new ProductReviewComparator()); break; case "date" : Collections.sort(c.getProducts(),new ProductDateComparator()); break; case "saleCount" : Collections.sort(c.getProducts(),new ProductSaleCountComparator()); break; case "price": Collections.sort(c.getProducts(),new ProductPriceComparator()); break; case "all": Collections.sort(c.getProducts(),new ProductAllComparator()); break; } } request.setAttribute("c", c); return "category.jsp"; } public String search(HttpServletRequest request, HttpServletResponse response, Page page){ String keyword = request.getParameter("keyword"); List<Product> ps= new ProductDAO().search(keyword,0,20); productDAO.setSaleAndReviewNumber(ps); request.setAttribute("ps",ps); return "searchResult.jsp"; } public String buyone(HttpServletRequest request, HttpServletResponse response, Page page) { int pid = Integer.parseInt(request.getParameter("pid")); int num = Integer.parseInt(request.getParameter("num")); Product p = productDAO.get(pid); int oiid = 0; User user =(User) request.getSession().getAttribute("user"); boolean found = false; List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId()==p.getId()){ oi.setNumber(oi.getNumber()+num); orderItemDAO.update(oi); found = true; oiid = oi.getId(); break; } } if(!found){ OrderItem oi = new OrderItem(); oi.setUser(user); oi.setNumber(num); oi.setProduct(p); orderItemDAO.add(oi); oiid = oi.getId(); } return "@forebuy?oiid="+oiid; } public String buy(HttpServletRequest request, HttpServletResponse response, Page page){ String[] oiids=request.getParameterValues("oiid"); List<OrderItem> ois = new ArrayList<>(); float total = 0; for (String strid : oiids) { int oiid = Integer.parseInt(strid); OrderItem oi= orderItemDAO.get(oiid); total +=oi.getProduct().getPromotePrice()*oi.getNumber(); ois.add(oi); } request.getSession().setAttribute("ois", ois); request.setAttribute("total", total); return "buy.jsp"; } public String addCart(HttpServletRequest request, HttpServletResponse response, Page page) { int pid = Integer.parseInt(request.getParameter("pid")); Product p = productDAO.get(pid); int num = Integer.parseInt(request.getParameter("num")); User user =(User) request.getSession().getAttribute("user"); boolean found = false; List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId()==p.getId()){ oi.setNumber(oi.getNumber()+num); orderItemDAO.update(oi); found = true; break; } } if(!found){ OrderItem oi = new OrderItem(); oi.setUser(user); oi.setNumber(num); oi.setProduct(p); orderItemDAO.add(oi); } return "%success"; } public String cart(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); request.setAttribute("ois", ois); return "cart.jsp"; } public String changeOrderItem(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); if(null==user) return "%fail"; int pid = Integer.parseInt(request.getParameter("pid")); int number = Integer.parseInt(request.getParameter("number")); List<OrderItem> ois = orderItemDAO.listByUser(user.getId()); for (OrderItem oi : ois) { if(oi.getProduct().getId()==pid){ oi.setNumber(number); orderItemDAO.update(oi); break; } } return "%success"; } public String deleteOrderItem(HttpServletRequest request, HttpServletResponse response, Page page){ User user =(User) request.getSession().getAttribute("user"); if(null==user) return "%fail"; int oiid = Integer.parseInt(request.getParameter("oiid")); orderItemDAO.delete(oiid); return "%success"; } public String createOrder(HttpServletRequest request, HttpServletResponse response, Page page){ User user =(User) request.getSession().getAttribute("user"); String address = request.getParameter("address"); String post = request.getParameter("post"); String receiver = request.getParameter("receiver"); String mobile = request.getParameter("mobile"); String userMessage = request.getParameter("userMessage"); String orderCode = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) +RandomUtils.nextInt(10000); Order order = new Order(); order.setOrderCode(orderCode); order.setAddress(address); order.setPost(post); order.setReceiver(receiver); order.setMobile(mobile); order.setUserMessage(userMessage); order.setCreateDate(new Date()); order.setUser(user); order.setStatus(OrderDAO.waitPay); orderDAO.add(order); List<OrderItem> ois= (List<OrderItem>) request.getSession().getAttribute("ois"); float total =0; for (OrderItem oi: ois) { oi.setOrder(order); orderItemDAO.update(oi); total+=oi.getProduct().getPromotePrice()*oi.getNumber(); } return "@forealipay?oid="+order.getId() +"&total="+total; } public String alipay(HttpServletRequest request, HttpServletResponse response, Page page){ return "alipay.jsp"; } public String payed(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order order = orderDAO.get(oid); order.setStatus(OrderDAO.waitDelivery); order.setPayDate(new Date()); new OrderDAO().update(order); request.setAttribute("o", order); return "payed.jsp"; } public String bought(HttpServletRequest request, HttpServletResponse response, Page page) { User user =(User) request.getSession().getAttribute("user"); List<Order> os= orderDAO.list(user.getId(),OrderDAO.delete); orderItemDAO.fill(os); request.setAttribute("os", os); return "bought.jsp"; } public String confirmPay(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); orderItemDAO.fill(o); request.setAttribute("o", o); return "confirmPay.jsp"; } public String orderConfirmed(HttpServletRequest request, HttpServletResponse response, Page page) { int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); o.setStatus(OrderDAO.waitReview); o.setConfirmDate(new Date()); orderDAO.update(o); return "orderConfirmed.jsp"; } public String deleteOrder(HttpServletRequest request, HttpServletResponse response, Page page){ int oid = Integer.parseInt(request.getParameter("oid")); Order o = orderDAO.get(oid); o.setStatus(OrderDAO.delete); orderDAO.update(o); return "%success"; } }


HOW2J公众号,关注后实时获知最新的教程和优惠活动,谢谢。


问答区域    
2019-08-19 单价和商品总价也是彩蛋吗?
挺爷不解释

rt




1 个答案

how2j
答案时间:2019-08-20
啊?



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到




2018-10-03 我的笔记
猪猪女孩

站长,我的笔记 里面为什么只显示一页内容?




1 个答案

how2j
答案时间:2018-10-03
因为没做分页,都在这里了



回答已经提交成功,正在审核。 请于 我的回答 处查看回答记录,谢谢
答案 或者 代码至少填写一项, 如果是自己有问题,请重新提问,否则站长有可能看不到




2018-04-26 有个小问题
2018-01-12 那个卖家发货几个字下面的日期没写出来
2017-04-21 请问这个项目的数据库配置在哪里?


提问太多,页面渲染太慢,为了加快渲染速度,本页最多只显示几条提问。还有 1 条以前的提问,请 点击查看

提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 实践项目-天猫整站J2EE-我的订单页操作 的提问

尽量提供截图代码异常信息,有助于分析和解决问题。 也可进本站QQ群交流: 578362961
提问尽量提供完整的代码,环境描述,越是有利于问题的重现,您的问题越能更快得到解答。
对教程中代码有疑问,请提供是哪个步骤,哪一行有疑问,这样便于快速定位问题,提高问题得到解答的速度
在已经存在的几千个提问里,有相当大的比例,是因为使用了和站长不同版本的开发环境导致的,比如 jdk, eclpise, idea, mysql,tomcat 等等软件的版本不一致。
请使用和站长一样的版本,可以节约自己大量的学习时间。 站长把教学中用的软件版本整理了,都统一放在了这里, 方便大家下载: https://how2j.cn/k/helloworld/helloworld-version/1718.html

上传截图