ssm中分页问题

2 篇文章 0 订阅
1 篇文章 0 订阅

分页考虑采用ajax实现局部刷新
注意:1.如果是搜索后结果的分页,分页显示时也要注意把搜索的参数值传递过去
2.分页必须对页号进行处理,判断页号的实际值,使其在页码范围内
3.分页一般涉及几个方面:总记录数,总页数,当前页,当前页记录数

   	<span onclick="pageStore(this)">上一页</span>
   <span onclick="pageStore(this)">${currPageNo}</span>
    	 <span onclick="pageStore(this)">${currPageNo+1}</span>
  	<span onclick="pageStore(this)">下一页</span>
    	var num = $(obj).html();
	if(num=="上一页")
		num=${currPageNo-1};
		if(num=="下一页")
			num=${currPageNo+1};
		
			alert(num);
			
	var pageType = $('#pageType').val();
	alert(pageType);
	
	var alias =$("#alias").val();
	
	$.ajax({
		type:"post",
		url:"${pageContext.request.contextPath}/user/searchStore.action",
		data:{"alias":alias,"currPageNo":num,"pageType":pageType},
		success:function(msg){
			//var map = $.parseJSON(msg);
			var allStr ='<div  id="index_first3"><p><input type="text"  id="content" value="已为您搜索到以下内容(按照店铺名称搜索)"/><input type="button"  value="搜索" id="search" onclick="searchStore()"/><input type="hidden" value="'+pageType+'" id="pageType"><input type="hidden" value="'+alias+'" id="alias"></p>';
			var pageStr='';
			var storeStr='';
			$.each(msg,function(key,value){
				//集合嵌套集合,分页、商家显示
				if(key=="所有店铺"){
					alert(key);
					if(value!=null){
						$.each(value,function(i,store){
							storeStr=storeStr+'<div class="store"><div class="img"><img src="../img/boy.jpg" /></div><div  class="store_content" ><p><a href="${pageContext.request.contextPath }/user/businessUI.action?stids='+store.stids+'&uids=${users.uids}">店家:'+store.alias +'</a></p><p>店家宗旨:'+store.title+'</p></div></div>';
							
						});
					}
					
				}
				if(key=="分页"){
					alert(key);
					$.each(value,function(allPage,currPageNo){
						
						if(allPage==1){
							pageStr=pageStr+'<div class="page" ><span>共'+${allPage}+'页</span></div>';
						}else
							if(allPage==2){
								pageStr=pageStr+'<div class="page" ><span>共${allPage}页</span><span onclick="pageStore(this)">上一页</span><span onclick="pageStore(this)">${currPageNo}</span></span><span onclick="pageStore(this)">${currPageNo+1}</span><span onclick="pageStore(this)">下一页</span></div>';
								}else if(allPage>=3){
									pageStr=pageStr+'<div class="page" ><span>共${allPage}页</span><span onclick="pageStore(this)">上一页</span><span onclick="pageStore(this)">${currPageNo}</span><span onclick="pageStore(this)">${currPageNo+1}</span><span onclick="pageStore(this)">${currPageNo+2}</span><span onclick="pageStore(this)">下一页</span></div>';
							}
					});
				}
				
				
				
			});
			allStr=allStr+storeStr+pageStr+'</div>';
			alert(allStr);
			$('#index_first3').remove();
		
			$('#index_first2').after(allStr);
		}
		
	});
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值