この記事では、参考のための全員のニュースリストページネーションクエリのJavaコードを共有しています。特定のコンテンツは次のとおりです
パッケージcom.ibeifeng.test; //ニューステストクラスの作成パブリッククラスNewtest {private long id; private string title; private string content; private string著者; public newtest(){super();} public newtest(long id、string title、string content、string auther){this.id = id; this.title = title; this.content = content; this.author = author;} public long getId(){return id;} public void setid(long id){this.id = id;} public string gettitle(){return title;} public void setitle(string title){this.title = title;} public string getContent(){return content;} public void setcontent()public void setcontent( string getauthor(){return author;} public void setauthor(string author){this.author = author;} @overridepublic string tostring(){return "Newtest [id =" + id + ",, content =" + content + "、著者=" +著者 + "];}}}} Query <%@ page Language = "Java" Import = "Java.util。*" PageEncoding = "utf-8"%> <%@ page Import = "com.ibeifeng.test.newtest"%> <%string path = request.getContextPath(); string basepath = request.getscheme() + "://" + request.getServername() + ":" + request.getServerport() + path + "/";%> <%list <newtest> list = new arraylist <new arraylist>(107); //ニュースラインの数を107; int 1; i <= 107; i <= 107; i < New Newtest(0L + I、I +「Rio Olympics」、「Maronは金メダルを獲得しました - 世界の5番目の男性「グランドスラム」の勝者は世界卓球世界 "、「福音書」); list.add(news); } // forの終わり... 107個のデータをセットに追加// int pageindex = 10; int ititleIndex = list.size(); //次の表を取得するintititlepages = ititleindex/10 +(ititleindex%10 == 0?0:1); //ページの総数int page = 4; if(str!= null &&!str.trim()。equals( "")){int newpage = integer.valueof(str); if(newPage <1){page = 1; } else if(newpage> ititlepages){page = ititlepages; } else {page = newPage; }} //新しいセットを作成します(各ページに表示されるニュースの合計数をサイズ)リスト<Newtest> listpage = new ArrayList <Newtest>(10)に107個のデータを保存します。 int ipa = 10; //ループボディにループの数を取得する//最後のページには7つのデータのみがあります(page == ititlepages){//現在のページ数が最後のページである場合、残りの数行はループ本体で数回実行されます。 } for(int i = 0; i <ipa; i ++){// i = 0;最初のループオンラインニューテストarr = list.get(i +(page -1) * 10)の最初の10データを取得します。 listpage.add(arr); }%> <html> <body> <table> <tr> <th>タイトル</th> <td>著者</td> <td> abstract </td> </tr> <%for listpage.get(i); %> <tr> <td> <%= temp.getTitle()%> </td> <td> <%= temp.getauthor()%> </td> <td> <%= temp.getContent()%> </td> </tr> <%} // ... boolean blast = page == ititlepages; %if(!bfirst){%> <a href = "test.jsp?page = <%= page-1%>&totopage = 11">前のページ</a> <%}%>%> <! - 最初のページにジャンプするとき、「前のページ」サブミッションダイアログボックスは表示されなくなりました。 href = "test.jsp?page = <%= page + 1%>&totopage = 11">次のページ</a> <%}%}%> <%= page%> <%= ititlepages%>ページ</body> </html>> </html>上記はこの記事のすべての内容です。みんなの学習に役立つことを願っています。誰もがwulin.comをもっとサポートすることを願っています。