基础分页,删除方法

script:

<script type="text/javascript">
$(function(){
	//var ctx = [[@{/}]];
	httpPost = function(URL, PARAMS) {
	    var temp = document.createElement("form");
	    temp.action = URL;
	    temp.method = "post";
	    temp.style.display = "none";

	    for (var x in PARAMS) {
	        var opt = document.createElement("textarea");
	        opt.name = x;
	        opt.value = PARAMS[x];
	        temp.appendChild(opt);
	    }

	    document.body.appendChild(temp);
	    temp.submit();

	    return temp;
	}
	httpGet = function(URL, PARAMS) {
	    var temp = document.createElement("form");
	    temp.action = URL;
	    temp.method = "get";
	    temp.style.display = "none";

	    for (var x in PARAMS) {
	        var opt = document.createElement("textarea");
	        opt.name = x;
	        opt.value = PARAMS[x];
	        temp.appendChild(opt);
	    }

	    document.body.appendChild(temp);
	    temp.submit();

	    return temp;
	}

	//处理分页
	var pageNo = parseInt($("#pageNo").val());
	//下一页
	nextPage = function (){
		var pageCount = parseInt($("#pageCount").text());
		
		//alert(pageCount);
		if(pageCount>pageNo){
			pageNo = pageNo+1;
			$("#pageNo1").text(pageNo);
			$("#pageNo2").text(pageNo);
			alert(pageNo+"pageCount"+pageCount);
			//window.location.href = ctxPath+"/index?page="+pageNo;
			httpGet("index",{"pageNo":pageNo});
		}
	}
	//上一页
	prePage = function (){
		if(pageNo>1){
			pageNo = pageNo-1;
			$("#pageNo1").text(pageNo);
			$("#pageNo2").text(pageNo);
			alert(pageNo+">1");
			//window.location.href = ctxPath+"/jkfwList?page="+pageNo;//改
			httpGet("index",{"pageNo":pageNo});
		}
	}
	//跳转到任意页
	$("#pageGoTo").click(function(){
		pageNo = parseInt($("#page").val())-1;
		//alert(pageNo);
		//window.location.href = ctxPath+"/jkfwList?page="+pageNo;//改
		httpGet("index",{"pageNo":pageNo});
	});
	
	//删除
	deleteUser = function(userId){
		Dialog.confirm('警告:您确认要删除吗?',function(){
			 $(function(){
					$.ajax({
						type:"post",
						url:"deleteUser",
						data:{"userId":userId},
						dataType:"json",
						success:function(res){
							if(res.status == '1'){
								Dialog.alert("删除成功!",function(){
									//window.location.href = "@{|/index|}";
									httpGet("index","");
								});
			 				}else{
			 					Dialog.alert("删除失败!");
			 				}	
						}
					});
			  });
		});
		
	}
});
	
</script>

html:

<div class="list-footer">
			<div class="list-page">
				<ul class="list-pagecontent" style="list-style:none;">
					<li><a class="leftborder"> « </a></li>
					<li><a onclick="prePage()"> &lt; </a></li>
					<li><a class="active" id="pageNo1" th:text="${pageNo}+1">1</a></li>
					<li class="disabled"><a onclick="nextPage()"> &gt; </a></li>
					<li class="disabled"><a> » </a></li>
					<li class="pageGoto"><span>总记录</span> <span class="num" th:text="${userCount}">8</span>
					
						<span>总页数</span> <span id="pageCount"  class="num" th:text="${pageCount}">1</span> 
						<span>当前第</span> 
						<span class="num" id="pageNo2" th:text="${pageNo}+1">1</span> <span>页</span> 
						<span>转到</span> 
						<input type="text" id="page" name="page" class="input pageInput" th:value="${pageNo}+1"/> 
						<span>页</span> 
						 <input type="button" class="btn blue" id="pageGoTo" value="确定" />
					</li>
				</ul>
				<input id="pageNo" type="hidden" th:value="${pageNo}" />
			</div>
		</div>

controller:

public String serverList(@RequestParam(value = "pageNo", defaultValue = "0") int pageNo,
			@RequestParam(value = "page.size", defaultValue = PAGE_SIZE) int pageSize,
			@RequestParam(value = "order.field", defaultValue = "FW_LX") String orderField,
			@RequestParam(value = "order.sort", defaultValue = "ASC") String orderSort,
			Model model,ServletRequest request){
			
		try {
			//初始化分页数据
			PageUtils pageUtils=new PageUtils(pageNo*pageSize,pageSize,orderField,orderSort);
			//搜索属性初始化
			//Map<String, Object> searchParams = Servlets.getParametersStartingWith(request, "search_");
			
			List<Map<String, Object>> userList = new ArrayList<>();
			
			userList = userListService.usersBypage(pageUtils);
			
			
			int userCount = userListService.finduSerCount();
			int pageCount = (userCount/Integer.parseInt(this.PAGE_SIZE))+1;
			model.addAttribute("pageCount", pageCount);
			model.addAttribute("userCount", userCount);
			//model.addAttribute("padeCount", jkfwCount);
			model.addAttribute("pageNo",pageNo);
			model.addAttribute("userList",userList);
			System.out.println(userList);
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值