Continue to the previous article for study.
3. Query order details
OrderServlet
public String load(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException { String oid = req.getParameter("oid"); Order order = orderService.load(oid); req.setAttribute("order", order); String btn = req.getParameter("btn");//btn explains which hyperlink the user clicks to access the req.setAttribute("btn", btn); return "/jsps/order/desc.jsp";}desc.jsp
<div> <span>Order number: ${order.oid } <c:choose> <c:when test="${order.status eq 1 }">(waiting for payment)</c:when> <c:when test="${order.status eq 2 }">(ready to ship)</c:when> <c:when test="${order.status eq 3 }">(waiting for confirmation)</c:when> <c:when test="${order.status eq 4 }">(transaction successful)</c:when> <c:when test="${order.status eq 5 }">(canceled)</c:when> </c:choose> Order time: ${order.ordertime }</span></div><div> <div> <dl> <dt>Consignee information</dt> <dd>${order.address }</dd> </dl> </div> <dl> <dt>Product list</dt> <dd> <table cellpadding="0" cellpacing="0"> <tr> <th>Product name</th> <th align="left">Unit price</th> <th align="left">Quantity</th> <th align="left">Subtotal</th> </tr> <c:forEach items="${order.orderItemList }" var="item"> <tr style="padding-top: 20px; padding-bottom: 20px;"> <td> <div> <img align="middle" src="<c:url value='/${item.book.image_b }'/>"/> <a href="<c:url value='/BookServlet?method=load&bid=${item.book.bid }'/>">${item.book.bname }</a> </div> </td> <td> <span>${item.book.currPrice }</span> </td> <td> <span>${item.quantity }</span> </td> <td> <span>${item.subtotal }</span> </td> </tr> </c:forEach> </table> </dd> </dl> </div> <div style="margin: 10px 10px 10px 550px;"> <span style="font-weight: 900; font-size: 15px;">Total amount: </span> <span>${order.total }</span><br/> <c:if test="${order.status eq 1 }"> <a href="<c:url value='/OrderServlet?method=paymentPre&oid=${order.oid }'/>"></a><br/> </c:if> <c:if test="${order.status eq 1 and btn eq 'cancel'}"> <a id="cancel" href="<c:url value='/OrderServlet?method=cancel&oid=${order.oid }'/>"> Cancel the order</a><br/> </c:if> <c:if test="${order.status eq 3 and btn eq 'confirm'}"> <a id="confirm" href="<c:url value='/OrderServlet?method=confirm&oid=${order.oid }'/>">Confirm the receipt</a><br/> </c:if> </div></div>4. Cancel the order and confirm receipt
The above is all the content of this article. I hope it will be helpful to everyone's learning and I hope everyone will support Wulin.com more.