jsp頁面用MultiPage做分頁

前台數據

<%Collection coll = (Collection)request.getAttribute("COLExchangeRate");
	 String pageNo =(String)request.getAttribute("pageNo");
	String totalSize =(String)request.getAttribute("totalSize");
	String pageSize = (String)request.getAttribute("pageSize");
%> 



<DataTable:table dataSrc="<%=coll%>" cssClass="table1"
												width="97%" align="center">
<!--放數據-->
</DataTable:table>


<MultiPage:navigator totalSize="<%=totalSize%>" pageSize="<%=pageSize%>" pageNo="<%=pageNo%>" formName="form1" type="text" >
                    </MultiPage:navigator >

後台傳入數據

String pageSize=request.getParameter("pageSize");
String pageNo=request.getParameter("pageNo");
Collection collExchangeRate = new ArrayList();


if("loadall".equals(policyCode)){
				int num=0;
				List<Map> tc=new ArrayList<Map>();
				tc=TodayContractDelegate.QueryAll();//查數據
				num=TodayContractDelegate.QueryAllNum();//查數據條數
				request.setAttribute("infoHashMap", tc);
				pageNo = request.getParameter("pageNo");
				
				if (StringUtils.isNullOrEmpty(pageNo)){
					pageNo = GLCst.PAGE_SIZE_ONE + "";
				}

				pageSize = "4";
				request.setAttribute("totalSize", ""
						+ num);
				request.setAttribute("pageSize", pageSize);
				request.setAttribute("pageNo", pageNo);
				collExchangeRate = getExchangeRateList(
						tc, Integer.parseInt(pageNo), Integer.parseInt(pageSize));
				request.setAttribute("COLExchangeRate", collExchangeRate);
				
			}



private List getExchangeRateList(Collection c,int pageNo,int pageSize){
			  List resultList = new ArrayList();
			  if(c instanceof List) {
				List list = (List)c;
				for(int i = (pageNo-1)*pageSize; i < pageNo*pageSize && i < list.size(); i++){
					resultList.add(list.get(i));
			  	}
			  }
			  return resultList;
		  }

 

转载于:https://my.oschina.net/aidaidai/blog/3001352

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值