{"id":632,"date":"2013-10-17T11:24:18","date_gmt":"2013-10-17T02:24:18","guid":{"rendered":"http:\/\/www.beeete2.com\/blog\/?p=632"},"modified":"2018-02-21T22:48:40","modified_gmt":"2018-02-21T13:48:40","slug":"post-632","status":"publish","type":"post","link":"https:\/\/www.beeete2.com\/blog\/?p=632","title":{"rendered":"SpringMVC\u3067Pagenation\u3092\u5b9f\u88c5\u3059\u308b\u65b9\u6cd5"},"content":{"rendered":"<p>\u6700\u8fd1\u3001SpringMVC\u3092\u4f7f\u3063\u3066\u8272\u3005\u4f5c\u3063\u3066\u304a\u308a\u307e\u3057\u305f\u3002<br \/>\n\u4eca\u307e\u3067\u8272\u3005\u306a\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u89e6\u3063\u3066\u3001\u305d\u306e\u5ea6\u306b\u632b\u6298\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001SpringMVC\u306f\u4f7f\u3048\u308b\u3068\u601d\u3046\u3088\u3046\u306b\u81f3\u308a\u307e\u3057\u305f\u3002<\/p>\n<p>\u696d\u52d9\u3067\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u3001SpringMVC\u3067Pagenation\u3092\u5b9f\u88c5\u3059\u308b\u6a5f\u4f1a\u304c\u3042\u3063\u305f\u306e\u3067\u3001\u3044\u308d\u3044\u308d\u8abf\u3079\u305f\u3068\u3053\u308d\u3001\u3042\u308a\u304c\u305f\u3044\u3053\u3068\u306b\u5b9f\u88c5\u3057\u3066\u3042\u308b\u30b5\u30f3\u30d7\u30eb\u304c\u3042\u308a\u307e\u3057\u305f\u306e\u3067\u3001\u4f7f\u308f\u305b\u3066\u3044\u305f\u3060\u304d\u307e\u3057\u305f\u3002<br \/>\n\u30bd\u30fc\u30b9\u30d5\u30a1\u30a4\u30eb\u306fGitHub\u306b\u30a2\u30c3\u30d7\u30ed\u30fc\u30c9\u3057\u3066\u304a\u304d\u307e\u3059\u3002<br \/>\nTwitter Bootstrap3\u3067\u753b\u9762\u3092\u4f5c\u6210\u3057\u3066\u3001\u6700\u7d42\u7684\u306a\u753b\u9762\u30a4\u30e1\u30fc\u30b8\u306f\u3053\u3093\u306a\u611f\u3058\u306b\u306a\u308a\u307e\u3059\u3002<br \/>\n<!--more--><br \/>\n<a href=\"https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2013\/10\/pagenation.png\"><img decoding=\"async\" src=\"https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2013\/10\/pagenation.png\" alt=\"pagenation\" width=\"1210\" height=\"1001\" class=\"alignnone size-full wp-image-633\" srcset=\"https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2013\/10\/pagenation.png 1210w, https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2013\/10\/pagenation-300x248.png 300w, https:\/\/www.beeete2.com\/blog\/wp-content\/uploads\/2013\/10\/pagenation-1024x847.png 1024w\" sizes=\"(max-width: 1210px) 100vw, 1210px\" \/><\/a><\/p>\n<h4>PagedListHolder<\/h4>\n<p>SpringMVC\u306bPagedListHolder\u3068\u3044\u3046\u30af\u30e9\u30b9\u304c\u3042\u308b\u306e\u3067\u3053\u3061\u3089\u3092\u4f7f\u3044\u307e\u3059\u3002<br \/>\n[java]<br \/>\nPagedListHolder&lt;Blog&gt; pagenation = new PagedListHolder&lt;&gt;(list);<br \/>\npagenation.setPage(Integer.parseInt(p)); \/\/ \u73fe\u5728\u30da\u30fc\u30b8\uff080\u304b\u3089\u958b\u59cb\uff09<br \/>\npagenation.setPageSize(12); \/\/ \uff11\u30da\u30fc\u30b8\u306e\u8868\u793a\u6570<br \/>\n[\/java]<br \/>\n\u305d\u306e\u4ed6\u306b\u3082\u3001getFirstPage\u3084getLastPage\u3084getPage\u306a\u3069\u5404\u7a2e\u5fc5\u8981\u306a\u30e1\u30bd\u30c3\u30c9\u304c\u7528\u610f\u3055\u308c\u3066\u304a\u308a\u307e\u3059\u3002<br \/>\nPagenation\u3092\u5b9f\u88c5\u3057\u305f\u3053\u3068\u304c\u3042\u308b\u4eba\u306f\u308f\u304b\u308b\u3068\u601d\u3044\u307e\u3059\u304c\u3001\u4e88\u3081\u8a08\u7b97\u3057\u3066\u304f\u308c\u308b\u306e\u306f\u697d\u3067\u3059\u306d\u3002<\/p>\n<h4>Pagenation\u306e\u5b9f\u88c5<\/h4>\n<p>\u30b5\u30f3\u30d7\u30eb\u304c\u63b2\u8f09\u3055\u308c\u3066\u3044\u308b\u30da\u30fc\u30b8\u3067\u306ftaglib\u3068\u3057\u3066\u5b9f\u88c5\u3057\u3066\u3042\u308a\u307e\u3057\u305f\u3002<\/p>\n<h5>WEB-INF\/tags\/pagenation.tg<\/h5>\n<p>[html]<br \/>\n&lt;%@ tag import=&quot;org.springframework.util.StringUtils&quot; %&gt;<br \/>\n&lt;%@ taglib uri=&quot;http:\/\/java.sun.com\/jsp\/jstl\/core&quot; prefix=&quot;c&quot; %&gt;<br \/>\n&lt;%@ attribute name=&quot;pagedListHolder&quot; required=&quot;true&quot; type=&quot;org.springframework.beans.support.PagedListHolder&quot; %&gt;<br \/>\n&lt;%@ attribute name=&quot;pagedLink&quot;       required=&quot;true&quot; type=&quot;java.lang.String&quot; %&gt;<br \/>\n&lt;c:if test=&quot;${pagedListHolder.pageCount &gt; 1}&quot;&gt;<br \/>\n  &lt;ul class=&quot;pagination&quot;&gt;<br \/>\n&lt;c:if test=&quot;${!pagedListHolder.firstPage}&quot;&gt;<br \/>\n    &lt;li&gt;&lt;a href=&quot;&lt;%= StringUtils.replace(pagedLink, &quot;~&quot;, String.valueOf(pagedListHolder.getPage()-1)) %&gt;&quot;&gt;Prev&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;\/c:if&gt;<br \/>\n&lt;c:if test=&quot;${pagedListHolder.firstLinkedPage &gt; 0}&quot;&gt;<br \/>\n    &lt;li&gt;&lt;a href=&quot;&lt;%= StringUtils.replace(pagedLink, &quot;~&quot;, &quot;0&quot;) %&gt;&quot;&gt;1&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;\/c:if&gt;<br \/>\n&lt;c:if test=&quot;${pagedListHolder.firstLinkedPage &gt; 1}&quot;&gt;<br \/>\n    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&#8230;&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;\/c:if&gt;<\/p>\n<p>&lt;c:forEach begin=&quot;${pagedListHolder.firstLinkedPage}&quot; end=&quot;${pagedListHolder.lastLinkedPage}&quot; var=&quot;i&quot;&gt;<br \/>\n&lt;c:choose&gt;<br \/>\n&lt;c:when test=&quot;${pagedListHolder.page == i}&quot;&gt;<br \/>\n    &lt;li class=&quot;active&quot;&gt;&lt;a&gt;${i+1}&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;\/c:when&gt;<br \/>\n&lt;c:otherwise&gt;<br \/>\n    &lt;li&gt;&lt;a href=&quot;&lt;%= StringUtils.replace(pagedLink, &quot;~&quot;, String.valueOf(jspContext.getAttribute(&quot;i&quot;))) %&gt;&quot;&gt;${i+1}&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;\/c:otherwise&gt;<br \/>\n&lt;\/c:choose&gt;<br \/>\n&lt;\/c:forEach&gt;<\/p>\n<p>&lt;c:if test=&quot;${pagedListHolder.lastLinkedPage &lt; pagedListHolder.pageCount &#8211; 2}&quot;&gt;<br \/>\n    &lt;li&gt;&lt;a href=&quot;#&quot;&gt;&#8230;&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;\/c:if&gt;<br \/>\n&lt;c:if test=&quot;${pagedListHolder.lastLinkedPage &lt; pagedListHolder.pageCount &#8211; 1}&quot;&gt;<br \/>\n    &lt;li&gt;&lt;a href=&quot;&lt;%= StringUtils.replace(pagedLink, &quot;~&quot;, String.valueOf(pagedListHolder.getPageCount()-1)) %&gt;&quot;&gt;${pagedListHolder.pageCount}&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;\/c:if&gt;<br \/>\n&lt;c:if test=&quot;${!pagedListHolder.lastPage}&quot;&gt;<br \/>\n    &lt;li&gt;&lt;a href=&quot;&lt;%= StringUtils.replace(pagedLink, &quot;~&quot;, String.valueOf(pagedListHolder.getPage()+1)) %&gt;&quot;&gt;Next&lt;\/a&gt;&lt;\/li&gt;<br \/>\n&lt;\/c:if&gt;<br \/>\n  &lt;\/ul&gt;<br \/>\n&lt;\/c:if&gt;<br \/>\n[\/html]<\/p>\n<h4>Pagenation\u306e\u547c\u3073\u51fa\u3057<\/h4>\n<p>\u4f5c\u6210\u3057\u305fPagenation\u3092\u547c\u3073\u51fa\u3059\u65b9\u6cd5\u3067\u3059\u304c\u3001<br \/>\n[html]<br \/>\n&lt;%@ taglib prefix=&quot;tg&quot; tagdir=&quot;\/WEB-INF\/tags&quot; %&gt;<br \/>\n&lt;c:url value=&quot;\/sample\/pagenation\/&quot; var=&quot;pagedLink&quot;&gt;<br \/>\n\t&lt;c:param name=&quot;p&quot; value=&quot;~&quot;\/&gt;<br \/>\n&lt;\/c:url&gt;<br \/>\n&lt;tg:pagenation pagedListHolder=&quot;${pagedListHolder}&quot; pagedLink=&quot;${pagedLink}&quot;\/&gt;<br \/>\n[\/html]<br \/>\n\u3053\u308c\u3060\u3051\u3067\u3059\u3002<br \/>\n\u5192\u982d\u3067pageLink\u3092\u5ba3\u8a00\u3057\u3066\u304a\u308a\u307e\u3059\u3002p\u306b\u8a2d\u5b9a\u3057\u3066\u3044\u308b&#8221;~&#8221;\u306f\u7f6e\u63db\u7528\u306e\u6587\u5b57\u5217\u3068\u306a\u3063\u3066\u304a\u308a\u3001\u5148\u307b\u3069\u306epagenation.tg\u3067URL\u751f\u6210\u6642\u306b\u30da\u30fc\u30b8\u6570\u306b\u7f6e\u63db\u3057\u3066\u304a\u308a\u307e\u3059\u3002<\/p>\n<h4>\u307e\u3068\u3081<\/h4>\n<p>\u30b3\u30f3\u30c8\u30ed\u30fc\u30e9\u30fc\u5074\u3067PagedListHolder\u3092\u7528\u610f\u3057\u3066\u30d3\u30e5\u30fc\u5074\u3067\u547c\u3073\u51fa\u3057\u51e6\u7406\u3092\u884c\u3046\u3060\u3051\u3067\u3001Pagenation\u3092\u4f5c\u6210\u3057\u3066\u304f\u308c\u308b\u306e\u306f\u672c\u5f53\u306b\u7c21\u5358\u3060\u3068\u601d\u3044\u307e\u3059\u3002<br \/>\n\u8ab2\u984c\u3068\u3057\u3066\u306f\u30c7\u30fc\u30bf\u30d9\u30fc\u30b9\u63a5\u7d9a\u3092\u884c\u3044\u30ea\u30b9\u30c8\u304c\u5927\u91cf\u306b\u3042\u308b\u5834\u5408\u3001\u30da\u30fc\u30b8\u5358\u4f4d\u3067\u8868\u793a\u3067\u304d\u308b\u304b\u3063\u3066\u3044\u3046\u3053\u3068\u3067\u3059\u306d\u3002<br \/>\n\u30ea\u30b9\u30c8\u6570\u304c\u9650\u3089\u308c\u3066\u3044\u308b\u30da\u30fc\u30b8\u3067\u306f\u3001\u975e\u5e38\u306b\u7c21\u5358\u306b\u4f7f\u7528\u3067\u304d\u308b\u306e\u3067\u6709\u52b9\u4fa1\u5024\u306f\u3042\u308b\u3068\u601d\u3044\u307e\u3059\u3002<\/p>\n<h4>\u53c2\u8003\u30da\u30fc\u30b8<\/h4>\n<p><a href=\"http:\/\/www.developer.com\/java\/web\/article.php\/10935_3830886_3\/A-Pagination-Technique-Using-Spring.htm\">A Pagination Technique Using Spring<\/a><\/p>\n<h4>\u4eca\u56de\u306e\u30d7\u30ed\u30b8\u30a7\u30af\u30c8<\/h4>\n<p><a href=\"http:\/\/bit.ly\/18b1c7m\" target=\"_blank\">https:\/\/github.com\/beeete2\/springmvc-testwebapp<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6700\u8fd1\u3001SpringMVC\u3092\u4f7f\u3063\u3066\u8272\u3005\u4f5c\u3063\u3066\u304a\u308a\u307e\u3057\u305f\u3002 \u4eca\u307e\u3067\u8272\u3005\u306a\u30d5\u30ec\u30fc\u30e0\u30ef\u30fc\u30af\u3092\u89e6\u3063\u3066\u3001\u305d\u306e\u5ea6\u306b\u632b\u6298\u3057\u3066\u3044\u307e\u3057\u305f\u304c\u3001SpringMVC\u306f\u4f7f\u3048\u308b\u3068\u601d\u3046\u3088\u3046\u306b\u81f3\u308a\u307e\u3057\u305f\u3002 \u696d\u52d9\u3067\u306f\u306a\u3044\u306e\u3067\u3059\u304c\u3001Spr &#8230; <\/p>\n","protected":false},"author":1,"featured_media":611,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[38],"tags":[77],"views":23674,"_links":{"self":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/632"}],"collection":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=632"}],"version-history":[{"count":9,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/632\/revisions"}],"predecessor-version":[{"id":1761,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/632\/revisions\/1761"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=\/wp\/v2\/media\/611"}],"wp:attachment":[{"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=632"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=632"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.beeete2.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=632"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}