实习知识整理9: 点击直接购买按钮后,跳转到确认订单页面

1. 为按钮绑定事件

<button id="addCartButton">加入购物车</button><br/>
     $("#buyButton").click(function () {
           if ('' !== loginUser) {
               // 如何将商品信息传递到后台,后台能够将内容在新的订单页面显示
               $("#buyItemForm").submit()  // 在用户已登录的情况下才能提交表单
           } else {
               window.location.href = "http://localhost:8082/project/login"  // 未登录跳转到登录界面
           }
     });

上述点击按钮后就是将表单中的信息传递到后台,然后后台返回到新页面中

 

2. 后端 接收到信息并将信息返回到新的页面中

@Controller
@RequestMapping("/order")
public class OrderController {

    @RequestMapping("/toConfirmOrder")
    public ModelAndView toConfirmOrder(ModelAndView mav, HttpSession session, Item item, Integer buyCount) throws Exception{
        // 需要将对应的信息放入到confirmOrder 页面中
        mav.addObject("item", item);
        mav.addObject("buyCount", buyCount);
        mav.setViewName("confirmOrder");
        return mav;
}

 

 

 3. 确认订单页面使用数据

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

是小蟹呀^

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值