bootStrap中pagination样式在jsp实现分页

 

1.在bootstap官网上查找分页模板

bootStrap中pagination样式在jsp实现分页_第1张图片2.放到jsp中添加需要跳转的接口

3.写接口返回数据到前端

@WebServlet("/findUserByPageServlet")
public class FindUserByPageServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        request.setCharacterEncoding("utf-8");

        //1.获取参数
        String currentPage = request.getParameter("currentPage");//当前页码
        String rows = request.getParameter("rows");//每页显示条数
        //参数为空的时候默认为第一页,显示10条数据
  
        if(currentPage == null || "".equals(currentPage)){

            currentPage = "1";
        }


        if(rows == null || "".equals(rows)){
            rows = "10";
        }
        
        //获取条件查询参数
        Map condition = request.getParameterMap();


        //2.调用service查询
        UserService service = new UserServiceImpl();
        PageBean pb = service.findUserByPage(currentPage,rows,condition);

        System.out.println(pb);

        //3.将PageBean存入request
        request.setAttribute("pb",pb);
        request.setAttribute("condition",condition);//将查询条件存入request
        //4.转发到list.jsp
        request.getRequestDispatcher("/mylist.jsp").forward(request,response);
    }

4.数据库查询方法

格式:select * from table where condition limit #{当前页码},#{每页显示的条数}

最后的效果bootStrap中pagination样式在jsp实现分页_第2张图片

 

你可能感兴趣的:(Java企业开发实战,bootstrap分页)