bootstrop分页ssm

来源:互联网 发布:mac os x 10.12黑苹果 编辑:程序博客网 时间:2024/04/29 15:33
//查询列表function findForAjax(currentPage,userId) {$.ajax({url : "/bills/bill/findForAjax",data : {"currentPage": currentPage,"userId" : userId}, type : "post",dataType : "json",async:false, // 如果为异步加载无法给分页标签绑定事件(执行js的时候ajax数据还未加载完成),如果用异步加载需要使用live动态绑定success : function (data){dealData(data);dealTable(data);dealPage(data);},error : function(XMLHttpRequest, textStatus, errorThrown) {alert(textStatus);stateCode(XMLHttpRequest);}});}
  • ${totalCount}
  • ${pageNo}
  • ${pageNo}
//查询列表function findForAjax(currentPage,userId) {$.ajax({url : "/bills/bill/findForAjax",data : {"currentPage": currentPage,"userId" : userId}, type : "post",dataType : "json",async:false, // 如果为异步加载无法给分页标签绑定事件(执行js的时候ajax数据还未加载完成),如果用异步加载需要使用live动态绑定success : function (data){dealData(data);dealTable(data);dealPage(data);},error : function(XMLHttpRequest, textStatus, errorThrown) {alert(textStatus);stateCode(XMLHttpRequest);}});}
// 页码展示function dealPage(data) {var str = "";for ( var i = 1; i <= data.totalPage; i++) {var strRed = "";var strOther = "";//str += "
  • "+i+"
  • ";if (i == data.currentPage) {strRed = "
  • "+i+"
  • ";}else{strOther = "
  • "+i+"
  • ";}str = str + strRed + strOther;}var str1 = "
  • ";var str2 = "
  • "+data.totalCount+"
  • ";var str3 = "
  • ";var str4 = "";var str5 = "";if (data.totalPage > 0){str4 = "
  • ";str5 = "
  • ";}var strAll = str1 + str2 + str3 + str4 + str + str5; $("#page").html(strAll);}
    // jquery实现动态绑定  分页$("#page").off("click").on("click","li[page = 'page']",function(){//alert("click");currentPage = $(this).attr("pageNo");findForAjax(currentPage,userId);});
    // 用户账单总行数Integer totalCount = billsServiceImpl.findTotalConut(userId);// 开始行Integer startRow = null;if (currentPage == null) {startRow = (Constant.bill.CURRENTPAGE - 1)*PAGESIZE;} else {// 开始行startRow = (currentPage - 1)*PAGESIZE;}// 总页数Integer totalPage = (totalCount % PAGESIZE == 0 ? totalCount/PAGESIZE : totalCount/PAGESIZE + 1);Map param = new HashMap();param.put("userId", userId);param.put("start", startRow);param.put("pageSize", PAGESIZE);List bills = billsServiceImpl.findBillsForPage(param);model.put("bills", bills);model.put("totalCount", totalCount);model.put("pageSize", PAGESIZE);model.put("currentPage", currentPage);model.put("totalPage", totalPage);