8月7日总结

1、在AlipayForm中添加一个变量index

private Integer index = 0;

2、在页面order.html中加入用于显示分页的代码

         <ul class="pagination fr">

  <li><a href="order?index=0">«第一页</a></li>

  <li th:each="pages,sts:${pagesList}" th:class="${alipayForm.index==sts.index}?'active':''">                                                 <a th:href="@{order(index=${sts.index})}" th:text="${pages}">1</a></li>

  <li><a th:href="@{order(index=${pagesList.size()}-1)}">最后一页»</a></li>

</ul>

3、在CartController中

        model.addAttribute("pagesList", cartService.searchOrderListCount(cartForm));

    model.addAttribute("orderList", cartService.searchOrderList(cartForm, alipayForm.getIndex()));

4、 在CartService中

public List<Integer> searchOrderListCount(CartForm frm) {

Double count = queryDao.executeForObject("Cart.selectAlipayHistoryListCount", frm, Double.class);

List<Integer> list = new ArrayList<>();

Integer pages = (int) Math.ceil(count/5);

for (int i=1; i<=pages; i++) {

list.add(i);

}

return list;                list表示总共有多少页

}

public List<AlipayForm> searchOrderList(CartForm frm, Integer index) {

List<AlipayForm> result = queryDao.executeForObjectList("Cart.selectAlipayHistoryList", frm, index*5, 5);

return result;             根据不同的区间来查询信息(index*5, 5)每页5条记录

}

5、在CartSqlMap中

        <select id="selectAlipayHistoryListCount" parameterClass="cn.agriculture.web.form.CartForm"

resultClass="java.lang.Double">

SELECT count(0)       查询表中记录的行数

FROM alipay_history

WHERE commodity_id is null

AND guest_id = #guestId#

ORDER BY update_time DESC

</select>

转载于:https://my.oschina.net/u/2413996/blog/488959

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值