how2j.cn

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

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

点击下载 winrar5.21
步骤 1 : 先运行,看到效果,再学习   
步骤 2 : 模仿和排错   
步骤 3 : 效果截图   
步骤 4 : OrderService   
步骤 5 : OrderServiceImpl   
步骤 6 : ForeAction.bought()   
步骤 7 : bought.jsp   
步骤 8 : boughtPage.jsp   

步骤 1 :

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

edit
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
效果截图
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service; import java.util.List; import com.how2java.tmall.pojo.Order; import com.how2java.tmall.pojo.OrderItem; import com.how2java.tmall.pojo.User; public interface OrderService extends BaseService { public static final String waitPay = "waitPay"; public static final String waitDelivery = "waitDelivery"; public static final String waitConfirm = "waitConfirm"; public static final String waitReview = "waitReview"; public static final String finish = "finish"; public static final String delete = "delete"; public float createOrder(Order order, List<OrderItem> ois); public List<Order> listByUserWithoutDelete(User user); }
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
package com.how2java.tmall.service.impl; import java.util.List; import org.hibernate.criterion.DetachedCriteria; import org.hibernate.criterion.Restrictions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Transactional; import com.how2java.tmall.pojo.Order; import com.how2java.tmall.pojo.OrderItem; import com.how2java.tmall.pojo.User; import com.how2java.tmall.service.OrderItemService; import com.how2java.tmall.service.OrderService; @Service public class OrderServiceImpl extends BaseServiceImpl implements OrderService { @Autowired OrderItemService orderItemService; @Transactional(propagation=Propagation.REQUIRED,rollbackForClassName="Exception") public float createOrder(Order order, List<OrderItem> ois) { save(order); float total =0; for (OrderItem oi: ois) { oi.setOrder(order); orderItemService.update(oi); total+=oi.getProduct().getPromotePrice()*oi.getNumber(); } return total; } @Override public List<Order> listByUserWithoutDelete(User user){ DetachedCriteria dc = DetachedCriteria.forClass(clazz); dc.add(Restrictions.eq("user", user)); dc.add(Restrictions.ne("status", OrderService.delete)); return findByCriteria(dc); } }
步骤 6 :

ForeAction.bought()

edit
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
@Action("forebought") public String bought() { User user =(User) ActionContext.getContext().getSession().get("user"); orders= orderService.listByUserWithoutDelete(user); orderItemService.fill(orders); return "bought.jsp"; }
package com.how2java.tmall.action; import java.text.SimpleDateFormat; import java.util.ArrayList; import java.util.Collections; import java.util.Date; import java.util.List; import org.apache.commons.lang.xwork.math.RandomUtils; import org.apache.struts2.convention.annotation.Action; import org.springframework.web.util.HtmlUtils; import com.how2java.tmall.comparator.ProductAllComparator; import com.how2java.tmall.comparator.ProductDateComparator; import com.how2java.tmall.comparator.ProductPriceComparator; import com.how2java.tmall.comparator.ProductReviewComparator; import com.how2java.tmall.comparator.ProductSaleCountComparator; import com.how2java.tmall.pojo.OrderItem; import com.how2java.tmall.pojo.Product; import com.how2java.tmall.pojo.User; import com.how2java.tmall.service.OrderService; import com.how2java.tmall.service.ProductImageService; import com.opensymphony.xwork2.ActionContext; public class ForeAction extends Action4Result { @Action("forebought") public String bought() { User user =(User) ActionContext.getContext().getSession().get("user"); orders= orderService.listByUserWithoutDelete(user); orderItemService.fill(orders); return "bought.jsp"; } @Action("forepayed") public String payed() { t2p(order); order.setStatus(OrderService.waitDelivery); order.setPayDate(new Date()); orderService.update(order); return "payed.jsp"; } @Action("forealipay") public String forealipay(){ return "alipay.jsp"; } @Action("forecreateOrder") public String createOrder(){ List<OrderItem> ois= (List<OrderItem>) ActionContext.getContext().getSession().get("orderItems"); if(ois.isEmpty()) return "login.jsp"; User user =(User) ActionContext.getContext().getSession().get("user"); String orderCode = new SimpleDateFormat("yyyyMMddHHmmssSSS").format(new Date()) +RandomUtils.nextInt(10000); order.setOrderCode(orderCode); order.setCreateDate(new Date()); order.setUser(user); order.setStatus(OrderService.waitPay); total = orderService.createOrder(order, ois); return "alipayPage"; } @Action("foredeleteOrderItem") public String deleteOrderItem(){ orderItemService.delete(orderItem); return "success.jsp"; } @Action("forechangeOrderItem") public String changeOrderItem() { User user =(User) ActionContext.getContext().getSession().get("user"); List<OrderItem> ois = orderItemService.list("user",user,"order", null); for (OrderItem oi : ois) { if(oi.getProduct().getId()==product.getId()){ oi.setNumber(num); orderItemService.update(oi); break; } } return "success.jsp"; } @Action("forecart") public String cart() { User user =(User) ActionContext.getContext().getSession().get("user"); orderItems = orderItemService.list("user",user,"order", null); for (OrderItem orderItem : orderItems) productImageService.setFirstProdutImage(orderItem.getProduct()); return "cart.jsp"; } @Action("foreaddCart") public String addCart() { User user =(User) ActionContext.getContext().getSession().get("user"); boolean found = false; List<OrderItem> ois = orderItemService.list("user",user,"order", null); for (OrderItem oi : ois) { if(oi.getProduct().getId()==product.getId()){ oi.setNumber(oi.getNumber()+num); orderItemService.update(oi); found = true; break; } } if(!found){ OrderItem oi = new OrderItem(); oi.setUser(user); oi.setNumber(num); oi.setProduct(product); orderItemService.save(oi); } return "success.jsp"; } @Action("forebuy") public String buy() { orderItems = new ArrayList<>(); for (int oiid : oiids) { OrderItem oi= (OrderItem) orderItemService.get(oiid); total +=oi.getProduct().getPromotePrice()*oi.getNumber(); orderItems.add(oi); productImageService.setFirstProdutImage(oi.getProduct()); } ActionContext.getContext().getSession().put("orderItems", orderItems); return "buy.jsp"; } @Action("forebuyone") public String buyone() { User user =(User) ActionContext.getContext().getSession().get("user"); boolean found = false; List<OrderItem> ois = orderItemService.list("user",user,"order", null); for (OrderItem oi : ois) { if(oi.getProduct().getId()==product.getId()){ oi.setNumber(oi.getNumber()+num); orderItemService.update(oi); found = true; oiid = oi.getId(); break; } } if(!found){ OrderItem oi = new OrderItem(); oi.setUser(user); oi.setNumber(num); oi.setProduct(product); orderItemService.save(oi); oiid = oi.getId(); } return "buyPage"; } @Action("foresearch") public String search(){ products= productService.search(keyword,0,20); productService.setSaleAndReviewNumber(products); for (Product product : products) productImageService.setFirstProdutImage(product); return "searchResult.jsp"; } @Action("forecategory") public String category(){ t2p(category); productService.fill(category); productService.setSaleAndReviewNumber(category.getProducts()); if(null!=sort){ switch(sort){ case "review": Collections.sort(category.getProducts(),new ProductReviewComparator()); break; case "date" : Collections.sort(category.getProducts(),new ProductDateComparator()); break; case "saleCount" : Collections.sort(category.getProducts(),new ProductSaleCountComparator()); break; case "price": Collections.sort(category.getProducts(),new ProductPriceComparator()); break; case "all": Collections.sort(category.getProducts(),new ProductAllComparator()); break; } } return "category.jsp"; } @Action("foreloginAjax") public String loginAjax() { user.setName(HtmlUtils.htmlEscape(user.getName())); User user_session = userService.get(user.getName(),user.getPassword()); if(null==user_session) return "fail.jsp"; ActionContext.getContext().getSession().put("user", user_session); return "success.jsp"; } @Action("forecheckLogin") public String checkLogin() { User u =(User) ActionContext.getContext().getSession().get("user"); if(null==u) return "fail.jsp"; else return "success.jsp"; } @Action("foreproduct") public String product() { t2p(product); productImageService.setFirstProdutImage(product); productSingleImages = productImageService.list("product",product,"type", ProductImageService.type_single); productDetailImages = productImageService.list("product",product,"type", ProductImageService.type_detail); product.setProductSingleImages(productSingleImages); product.setProductDetailImages(productDetailImages); propertyValues = propertyValueService.listByParent(product); reviews = reviewService.listByParent(product); productService.setSaleAndReviewNumber(product); return "product.jsp"; } @Action("forelogout") public String logout() { ActionContext.getContext().getSession().remove("user"); return "homePage"; } @Action("forelogin") public String login() { user.setName(HtmlUtils.htmlEscape(user.getName())); User user_session = userService.get(user.getName(),user.getPassword()); if(null==user_session){ msg= "账号密码错误"; return "login.jsp"; } ActionContext.getContext().getSession().put("user", user_session); return "homePage"; } @Action("foreregister") public String register() { user.setName(HtmlUtils.htmlEscape(user.getName())); boolean exist = userService.isExist(user.getName()); if(exist){ msg = "用户名已经被使用,不能使用"; return "register.jsp"; } userService.save(user); return "registerSuccessPage"; } @Action("forehome") public String home() { categorys = categoryService.list(); productService.fill(categorys); productService.fillByRow(categorys); return "home.jsp"; } }
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
<%@ 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/boughtPage.jsp"%> <%@include file="include/footer.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/boughtPage.jsp"%>
<%@include file="include/footer.jsp"%>
增值内容,请先登录
完整的SSH模仿天猫项目,使用J2SE、前端技术(包含所有前端jsp文件)、J2EE,SSH一整套技术栈, 从无到有涵盖全部133个知识点,571个开发步骤, 充实SSH项目经验,为简历加上一个有吸引力的砝码.
增值内容,点击购买
使用爬虫已经被系统记录,请勿使用爬虫,增大封号风险。 如果是误封 ,请联系站长,谢谢
boughtPage.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" isELIgnored="false"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %> <script> var deleteOrder = false; var deleteOrderid = 0; $(function(){ $("a[orderStatus]").click(function(){ var orderStatus = $(this).attr("orderStatus"); if('all'==orderStatus){ $("table[orderStatus]").show(); } else{ $("table[orderStatus]").hide(); $("table[orderStatus="+orderStatus+"]").show(); } $("div.orderType div").removeClass("selectedOrderType"); $(this).parent("div").addClass("selectedOrderType"); }); $("a.deleteOrderLink").click(function(){ deleteOrderid = $(this).attr("oid"); deleteOrder = false; $("#deleteConfirmModal").modal("show"); }); $("button.deleteConfirmButton").click(function(){ deleteOrder = true; $("#deleteConfirmModal").modal('hide'); }); $('#deleteConfirmModal').on('hidden.bs.modal', function (e) { if(deleteOrder){ var page="foredeleteOrder"; $.post( page, {"order.id":deleteOrderid}, function(result){ if("success"==result){ $("table.orderListItemTable[oid="+deleteOrderid+"]").hide(); } else{ location.href="login.jsp"; } } ); } }) $(".ask2delivery").click(function(){ var link = $(this).attr("link"); $(this).hide(); page = link; $.ajax({ url: page, success: function(result){ alert("卖家已秒发,刷新当前页面,即可进行确认收货") } }); }); }); </script> <div class="boughtDiv"> <div class="orderType"> <div class="selectedOrderType"><a orderStatus="all" href="#nowhere">所有订单</a></div> <div><a orderStatus="waitPay" href="#nowhere">待付款</a></div> <div><a orderStatus="waitDelivery" href="#nowhere">待发货</a></div> <div><a orderStatus="waitConfirm" href="#nowhere">待收货</a></div> <div><a orderStatus="waitReview" href="#nowhere" class="noRightborder">待评价</a></div> <div class="orderTypeLastOne"><a class="noRightborder"> </a></div> </div> <div style="clear:both"></div> <div class="orderListTitle"> <table class="orderListTitleTable"> <tr> <td>宝贝</td> <td width="100px">单价</td> <td width="100px">数量</td> <td width="120px">实付款</td> <td width="100px">交易操作</td> </tr> </table> </div> <div class="orderListItem"> <c:forEach items="${orders}" var="o"> <table class="orderListItemTable" orderStatus="${o.status}" oid="${o.id}"> <tr class="orderListItemFirstTR"> <td colspan="2"> <b><fmt:formatDate value="${o.createDate}" pattern="yyyy-MM-dd HH:mm:ss"/></b> <span>订单号: ${o.orderCode} </span> </td> <td colspan="2"><img width="13px" src="img/site/orderItemTmall.png">天猫商场</td> <td colspan="1"> <a class="wangwanglink" href="#nowhere"> <div class="orderItemWangWangGif"></div> </a> </td> <td class="orderItemDeleteTD"> <a class="deleteOrderLink" oid="${o.id}" href="#nowhere"> <span class="orderListItemDelete glyphicon glyphicon-trash"></span> </a> </td> </tr> <c:forEach items="${o.orderItems}" var="oi" varStatus="st"> <tr class="orderItemProductInfoPartTR" > <td class="orderItemProductInfoPartTD"><img width="80" height="80" src="img/productSingle_middle/${oi.product.firstProductImage.id}.jpg"></td> <td class="orderItemProductInfoPartTD"> <div class="orderListItemProductLinkOutDiv"> <a href="foreproduct?product.id=${oi.product.id}">${oi.product.name}</a> <div class="orderListItemProductLinkInnerDiv"> <img src="img/site/creditcard.png" title="支持信用卡支付"> <img src="img/site/7day.png" title="消费者保障服务,承诺7天退货"> <img src="img/site/promise.png" title="消费者保障服务,承诺如实描述"> </div> </div> </td> <td class="orderItemProductInfoPartTD" width="100px"> <div class="orderListItemProductOriginalPrice">¥<fmt:formatNumber type="number" value="${oi.product.originalPrice}" minFractionDigits="2"/></div> <div class="orderListItemProductPrice">¥<fmt:formatNumber type="number" value="${oi.product.promotePrice}" minFractionDigits="2"/></div> </td> <c:if test="${st.count==1}"> <td valign="top" rowspan="${fn:length(o.orderItems)}" class="orderListItemNumberTD orderItemOrderInfoPartTD" width="100px"> <span class="orderListItemNumber">${o.totalNumber}</span> </td> <td valign="top" rowspan="${fn:length(o.orderItems)}" width="120px" class="orderListItemProductRealPriceTD orderItemOrderInfoPartTD"> <div class="orderListItemProductRealPrice">¥<fmt:formatNumber minFractionDigits="2" maxFractionDigits="2" type="number" value="${o.total}"/></div> <div class="orderListItemPriceWithTransport">(含运费:¥0.00)</div> </td> <td valign="top" rowspan="${fn:length(o.orderItems)}" class="orderListItemButtonTD orderItemOrderInfoPartTD" width="100px"> <c:if test="${o.status=='waitConfirm' }"> <a href="foreconfirmPay?order.id=${o.id}"> <button class="orderListItemConfirm">确认收货</button> </a> </c:if> <c:if test="${o.status=='waitPay' }"> <a href="forealipay?order.id=${o.id}&total=${o.total}"> <button class="orderListItemConfirm">付款</button> </a> </c:if> <c:if test="${o.status=='waitDelivery' }"> <span>待发货</span> <%-- <button class="btn btn-info btn-sm ask2delivery" link="admin_order_delivery?order.id=${o.id}">催卖家发货</button> --%> </c:if> <c:if test="${o.status=='waitReview' }"> <a href="forereview?order.id=${o.id}"> <button class="orderListItemReview">评价</button> </a> </c:if> </td> </c:if> </tr> </c:forEach> </table> </c:forEach> </div> </div>


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


提问之前请登陆
提问已经提交成功,正在审核。 请于 我的提问 处查看提问记录,谢谢
关于 已下架的-天猫整站SSH-我的订单页 的提问

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

上传截图