1、將guestAlipayConfirm.jsp頁面改爲guestAlipayConfirm.html頁面,爲了方便前臺修改html
2、本頁面的主要功能是實現匿名購買功能,填寫訂單信息可點擊登錄支付寶付款按鈕進行付款java
3、將jsp頁面中的標籤用html標籤的形式表示session
在html頁面的form表單中須要添加一項th:value="${goodsForm}"表示引用的是goodsForm中的數據app
2.完成頁面修改以後進行測試,出現"糧食"錯誤進行調試,能夠用debug進行調試jsp
3."糧食"錯誤須要在AlipayController和CartController頁面添加實例化方法
post
(1)goodsForm.type="糧食"的錯誤信息。測試
解決辦法:在AlipayController.java和CartController.java中須要對糧食進行實例化,附初值spa
(2)cartList==0的錯誤信息。debug
解決辦法:匿名購買時沒有購物車,可是寫成HTML時要求比較嚴格,因此必須添加購物車,因此在AlipayController.java中對購物車進行實例化。調試
.guestAlipay.jsp中:
<ul class="user_menu"> <jsp:include page="/WEB-INF/jsp/shop/userBar.jsp"></jsp:include> </ul> <h1> 您如今是匿名購買該商品,請認真填寫如下每項內容以保證商品可以順利到達您的手中。<br/> ${message}<form:errors path="*"></form:errors>(異常處理) </h1>改寫成: <span th:errors="${alipayForm.*}"></span> <span th:text="${message}"></span>
guestAlipay.jsp中
<form:form modelAttribute="alipayForm" action="guestAlipaySubmit" method="post"> <form:hidden path="outTradeNo" value="${alipayForm.outTradeNo}"/> <form:hidden path="subject" value="${alipayForm.subject}"/> <form:hidden path="body" value="${alipayForm.body}"/> <form:hidden path="price" value="${alipayForm.price}"/> <form:hidden path="showUrl" value="${alipayForm.showUrl}"/> <form:hidden path="commodityId" value="${alipayForm.commodityId}"/> <form:hidden path="guestId" value="${alipayForm.guestId}"/> <form:hidden path="count" value="${alipayForm.count}"/> </form:form>
改寫爲guestAlipay.html:
<form action="guestAlipaySubmit" th:object="${alipayForm}" method="post"> <input name="outTradeNo" type="hidden" th:value="${alipayForm.outTradeNo}" /> <input name="subject" type="hidden" th:value="${alipayForm.subject}" /> <input name="body" type="hidden" th:value="${alipayForm.body}" /> <input name="price" type="hidden" th:value="${alipayForm.price}" /> <input name="showUrl" type="hidden" th:value="${alipayForm.showUrl}" /> <input name="commodityId" type="hidden" th:value="${alipayForm.commodityId}" /> <input name="guestId" type="hidden" th:value="${alipayForm.guestId}" /> <input name="count" type="hidden" th:value="${alipayForm.count}" /> </form>
CartController.java中添加實例化方法:
@RequestMapping(value = "addCart", method = RequestMethod.POST) public String executeAddCart(Model model, HttpSession session, CartForm cartForm, Device device) throws SQLException { GoodsForm GoodsForm=new GoodsForm(); GoodsForm.setType("糧食"); model.addAttribute("goodsForm", GoodsForm); model.addAttribute("cartList", cartService.searchCartList(cartForm)); log.info("追加購物車");
AlipayController.java中添加實例化方法:
@RequestMapping(value = "guestAlipaySubmit", method = RequestMethod.POST) public String executeGuestAlipaySubmit(Device device, Model model, @Valid @ModelAttribute("alipayForm") AlipayForm alipayForm, BindingResult results) throws SQLException { GoodsForm goodsForm=new GoodsForm(); goodsForm.setType("糧食"); model.addAttribute("goodsForm", goodsForm); log.info("由匿名用戶購買商品向支付寶發起支付請求。");