private Integer cur_page = new Integer(1);//当前页 private Integer total_page = new Integer(1);//总页数 private Integer total_count = new Integer(0);//总行数 private Integer count_page = new Integer(20);//每页行数 //计算 总页数=总行数/每页条数+(不能整除就+1) this.total_page = this.total_count/this.count_page+(this.total_count%this.count_page==0?0:1); //计算 每页起始页=(当前页-1)*每页行数 this.cur_page = (this.cur_page-1)*this.total_count;
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <!doctype html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="Generator" content="EditPlus®"> <meta name="Author" content=""> <meta name="Keywords" content=""> <meta name="Description" content=""> <title>Document</title> </head> <body> <c:if test="${cur_page > 0 && cur_page <= total_page}"> <a href="${pageContext.request.contextPath}/waporder/myOrder?page=${cur_page+1}">下 一 页</a> <a href="${pageContext.request.contextPath}/waporder/myOrder?page=${cur_page-1}">上 一 页</a> </c:if> <c:if test="${cur_page < 1 }">已到达首页 <a href="${pageContext.request.contextPath}/waporder/myOrder?page=${cur_page+1}">下 一 页</a> </c:if> <c:if test="${cur_page > total_page }">已到达尾页 <a href="${pageContext.request.contextPath}/waporder/myOrder?page=${cur_page-1}">上 一 页</a> </c:if> <c:forEach items="${orderList}" var="ord"> <c:if test="${ord.wxOrderStatus=='新建' }"> <ul> <li><a href="${pageContext.request.contextPath}/waporder/orderDetail?danhao=${ord.wxDanhao}&type=${ord.wxOrderStatus}"> <div style="color: #000; line-height: 30px; padding: 0px 10px;"> 编号: ${ord.wxDanhao}<span style="float: right">${ord.wxOrderXiadanshijian}</span><br /> ${ord.wxOrderXiaolei}<span style="margin-left: 30px;">${ord.wxOrderPingpai}</span> <span style="float: right">${ord.wxOrderFuwuleixin} <span style="margin-left: 30px; color: #83caf7;">${ord.wxOrderStatus}</span> </span><br /> 描述: ${ord.wxOrderGuzhangjianshu} <br/><span>${ord.wxAddress.wxAddressProvince}${ord.wxAddress.wxAddressCity}${ord.wxAddress.wxAddressDistrict}${ord.wxAddress.wxAddressDetailed}</span> </div> </a></li> </ul> </c:if> </c:forEach> </body> </html>
@RequestMapping(value = "myOrder", method = RequestMethod.GET) public String myOrder( HttpSession session,Model model,String page,String type) { WxUser user = null; Integer pageInt = 1;//首页 默认 Integer rowsInt = 25;//每页条数 Integer total_page = 1 ;//总页数 默认 Long total = 1l;//总条数 默认 if(StringUtils.isNotBlank(page)){ pageInt = Integer.parseInt(page); } try{ user = getCurrentUser(session); if(user == null){ return "/wap/logo"; } }catch(Exception e){ e.printStackTrace(); return "/wap/logo"; } List<WxOrder> orderList = null; try{ total = orderService.getMyOrdersCount(user); if(null!=total && total.intValue() > 0 ){ total_page = total.intValue()/rowsInt+(total.intValue()%rowsInt==0?0:1); } if(pageInt > 0 && pageInt <= total_page){ orderList = orderService.getOrderList( user , (pageInt-1)*rowsInt, rowsInt); model.addAttribute("orderList",orderList); } }catch(Exception e){ e.printStackTrace(); } model.addAttribute("cur_page",pageInt); model.addAttribute("total_page",total_page); return "/wap/myorder"; }