bootstrop分页ssm

本文介绍了一个基于Ajax的账单分页查询功能实现方法,包括异步数据加载、页面元素绑定及动态分页显示等内容。
//查询列表
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 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);
     
    
   
  • select b.*, t.id tid, t.name, t.userId from bills b, bill_type t where b.typeId = t.id and b.userId = #{userId} order by b.billTime desc limit #{start} , #{pageSize}
  • 评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

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

    抵扣说明:

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

    余额充值