1.guestAlipay.jsp中
<ul class="user_menu"> <jsp:include page="/WEB-INF/jsp/shop/userBar.jsp"></jsp:include> </ul>
guestAlipay.html改写为:
<ul> <div th:replace="shop/userBar :: page-user-bar"></div> </ul>
2.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>
3.guestAlipay.jsp中
<h1>
您现在是匿名购买该商品,请认真填写以下每项内容以保证商品能够顺利到达您的手中。<br/>
${message}<form:errors path="*"></form:errors>
</h1>
guestAlipay.html改写为:
<h1>
您现在是匿名购买该商品,请认真填写以下每项内容以保证商品能够顺利到达您的手中。
<span th:errors="${alipayForm.*}"></span>
<span th:text="${message}"></span>
</h1>
4.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("追加购物车");
5.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("由匿名用户购买商品向支付宝发起支付请求。");
原文:http://my.oschina.net/u/2411768/blog/482791