舉例:
現在有一個A頁面JSP
想要呈現員工表格分頁
可以使用開始index跟需要多少筆資料包裝成一個方法
範例來源:Pagination in JSP - javatpoint
  public static List<Emp> getRecords(int start,int total){  
       List<Emp> list=new ArrayList<Emp>();  
       try{  
           Connection con=getConnection();  
           PreparedStatement ps=con.prepareStatement(  
"select * from emp limit "+(start-1)+","+total);  //注意正式專案要改成參數化
           ResultSet rs=ps.executeQuery();  
           while(rs.next()){  
               Emp e=new Emp();  
               e.setId(rs.getInt(1));  
               e.setName(rs.getString(2));  
               e.setSalary(rs.getFloat(3));  
               list.add(e);  
           }  
           con.close();  
       }catch(Exception e){System.out.println(e);}  
       return list;  
   }  
接著做成API方式
看你是使用Servlet還是springBoot方式
讓A網頁去傳參數去呼叫回傳JSON資料給A頁面
觸發AJAX刷新你的表格
刷新方式參考範例:
Pagination Example (NG1版本)
jQuery Pagination (JQ版本)
你先看一下,假如有問題再跟我講 :)