jsp实现的分页

	<div class="col-md-6">
			<nav aria-label="Page navigation">
				<ul class="pagination">
					<li><a href="${APP_PATH }/emps?pn=1">首页</a></li>
						<li> 
						  <c:if test="${pageInfo.hasPreviousPage}"	>
							<a href="${APP_PATH }/emps?pn=${pageInfo.pageNum-1}" aria-label="Previous">
								<span aria-hidden="true">&laquo;</span>
							</a>
						  </c:if>
						</li>

				           <c:forEach items="${pageInfo.navigatepageNums}" var="page_Num">
							   <c:if test="${page_Num == pageInfo.pageNum}">
								   <li class="active"><a href="#">${page_Num }</a></li>
						       </c:if>

							   <c:if test="${page_Num != pageInfo.pageNum}">
								   <li ><a href="${APP_PATH }/emps?pn=${page_Num }">${page_Num }</a></li>
							   </c:if>

						   </c:forEach>


						<li>
							<c:if test="${pageInfo.hasNextPage}"	>
							<a href="${APP_PATH }/emps?pn=${pageInfo.pageNum+1  }" aria-label="Next">
								<span aria-hidden="true">&raquo;</span>
							</a>
							</c:if>
						</li>
					<li><a href="${APP_PATH }/emps?pn=${pageInfo.pages  }">末页</a></li>
				</ul>
			</nav>
		</div>
	</div>
package com.controller;

import com.bean.Employee;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.service.EmpService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.List;
import java.util.Map;

@Controller
public class EmpController {

    @Autowired
    EmpService empService;

    @RequestMapping("/emps")
    public String emp(
        @RequestParam(value = "pn", defaultValue = "1") Integer pn,
       Map<String,Object> map) {

        //pn第一页传入的当前页,每页显示5数据
        PageHelper.startPage(pn, 5);
        //查询数据
        List<Employee> emps = empService.getAll();
        map.put("emps",emps);
        //封装,当前页有连续的5条
        PageInfo page = new PageInfo(emps,5);
        map.put("pageInfo",page);


            return "list";
    }

}

在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值