JSP µÄpager taglib ·ÖÒ³
1: ÎÒÃÇÐèÒªÏÂÔØpage±êÇ©µÄjar°ü; pager-taglib.jar
[ÑùÀý´úÂë]: http://jsptags.com/tags/navigation/pager/pager-taglib-2.0.war
½âѹwarÎļþ ÔÚ{..}\WEB-INF\lib\pager-taglib.jar
2:°ÑÕâ¸öjar ¿½±´µ½ÄãµÄweb¹¤³ÌµÄlibÖÐ;
3: 3-1 ¸Ã±êÇ©ÐèÒªÎÒÃÇÌṩ1¸ö×î¹Ø¼üµÄ²ÎÊý ---¡· ×ÜÊý¾ÝÁ¿ select count(*)µÄÖµ
3-2 ÿҳÏÔʾµÄ¼Ç¼Êý
3-3 Ò³ÂëµÄ¸öÊý
3-4 ÄãµÄÕâ¸öÓ¦ÓõÄurl
3-5 Èç¹ûÄãµÄÕâ¸öÓ¦ÓÃÓвÎÊýµÄ³¡ºÏ ÄãÐèÒªÉèÖÃurlµÄ²ÎÊý
4£ºÄ¬Èϵij¡ºÏ²éѯÊý¾Ý¿âµÄ¿ªÊ¼Ë÷Òý µÄ²ÎÊýÃû³ÆÎªpager.offset
5:
ºǫ́µÄ´¦Àí
ºǫ́µÄactionÖÐ ÔÚrequest.getParameter("pager.offset"); ÀïµÃµ½²éѯÊý¾Ý¿âµÄ¿ªÊ¼Ë÷Òý
²¢¼ÆËã²éѯµÄ×ÜÊý¾ÝÁ¿²¢½«¼ÆËãµÄ½á¹û±£´æÔÚrequset.setAttribute('totalpage');
°ÑÏà¹ØµÄ²éѯ½á¹ûÉèÖõ½requset.setAttribute('xxlist');
6: ǰ̨´¦Àí
ÔÚÏàÓ¦jspÒ³ÃæÉÏÌí¼Ó <%@ taglib uri="http://jsptags.com/tags/navigation/pager" prefix="pg" %>
È¡µÃcount(*)µÄÖµ
<%
Integer totalPage = (Integer)request.getAttribute("totalPage");
%>
<pg:pager
items="<%=totalPage%>" ----¡·count(*)Öµ
index="center" (ºöÂÔ)
maxPageItems="5" ÿҳÏÔʾµÄ¶àÉÙÐÐÊý¾Ý Õâ¸ö²ÎÊýºÍÎÒÃÇhibernateÖÐ maxResult ÊÇÒ»ÖµÄ
maxIndexPages="10" ÏÔʾµÄ×î´óÒ³Âë
isOffset="<%= true %>" (ºöÂÔ)
export="offset,currentPageNumber=pageNumber" (ºöÂÔ)
scope="request" &nbs
Ïà¹ØÎĵµ£º
(1)include ÔÚJSP±àÒë³ÉJavaÀàÎļþʱ£¬ÏȽ«includeÎļþÄÚÈݺϲ¢ºó£¬ÔÙ½øÐбàÒë
(2)jsp:include ÔËÐÐʱºÏ²¢,»á½«ÔËÐÐʱµÄ½á¹û°üº¬½øÀ´
(3)c:import ÔËÐÐʱºÏ²¢,»á½«ÔËÐÐʱµÄ½á¹û°üº¬½øÀ´
Òò´Ë£¬
£¨1£©ÀûÓÃinclude°üº¬µÄÒ³ÃæÖÐÈç¹û°üº¬Á˺ÍÔÒ ......
jspµÄÄÚÖöÔÏó¡¢¹¦ÄÜÒÔ¼°Ö÷Òª·½·¨
JspÄÚÖöÔÏó ¹¦ÄÜ Ö÷Òª·½·¨
out Ïò¿Í»§¶ËÊä³öÊý¾Ý print() println() flush() clear() isAutoFlush() getBufferSize() close() …………
request Ïò¿Í»§¶ËÇëÇóÊý¾Ý getAttributeNames() getCookies() getParameter() getParameterValues() ......
Ò»¸ötag¾ÍÊÇÒ»¸öÆÕͨµÄjavaÀ࣬ËüÎ©Ò»ÌØ±ðÖ®´¦ÊÇËü±ØÐë¼Ì³ÐTagSupport»òÕßBodyTagSupportÀà¡£ÕâÁ½¸öÀàÌṩÁËһЩ·½·¨£¬¸ºÔðjspÒ³ÃæºÍÄã±àдµÄÀàÖ®¼äµÄ½»»¥£¬ÀýÈçÊäÈ룬Êä³ö¡£¶øÕâÁ½¸öÀàÊÇÓÉjspÈÝÆ÷ÌṩµÄ£¬ÎÞÐ뿪·¢ÈËÔ±×Ô¼ºÊµÏÖ¡£»»¾ä»°Ëµ£¬ÄãÖ»Ðè°ÑʵÏÖÁËÒµÎñÂß¼µÄÀà¼Ì³ÐTagSupport»òÕßBodyTagSupport£¬ÔÙ×öÒ»Ð©ÌØ±ðµÄ¹¤× ......
JSPÒ³Ãæ¼ä´«µÝ²ÎÊý·½·¨½éÉÜ
±¾ÎĽéÉÜÁËJSPÒ³Ãæ¼ä´«µÝ²ÎÊýµÄ¼¸¸ö·½·¨¡£×îÖ±½ÓµÄ·½·¨¾ÍÊÇÖ±½ÓÔÚURLÇëÇóºóÌí¼Ó£¬²»¹ý¶à¸öÒ³ÃæµÄÇé¿ö»á¸´ÔÓһЩ¡£
JSPÒ³Ãæ¼ä´«µÝ²ÎÊýÊǾ³£ÐèҪʹÓõ½µÄ¹¦ÄÜ£¬ÓÐʱ»¹ÐèÒª¶à¸öJSPÒ³Ãæ¼ä´«µÝ²ÎÊý¡£ÏÂÃæ½éÉÜÒ»ÏÂʵÏֵķ½·¨¡£
£¨1£©Ö±½ÓÔÚURLÇëÇóºóÌí¼Ó
È磺< a href="thexuan.jsp?action=t ......
ÏÈsunÌá³öµÄÊÇServletÌåϵ£¬Õâ¸öÌåϵʹµÃʹÓÃJAVAµÄ³ÌÐòÔ±Ò²ÄÜ¿ª·¢»ùÓÚB/S¼Ü¹¹µÄWEBÓ¦ÓóÌÐò£¬Ê¹ÓÃServletÀཫHTTPÇëÇóºÍÏìÓ¦·â×°ÔÚ±ê×¼JAVAÀàÖÐÀ´ÊµÏÖ¸÷ÖÖWEBÓ¦Ó÷½°¸¡£
Ëæ×Å´óÁ¿µÄB/S¼Ü¹¹³ÌÐò¿ª·¢³öÀ´ÒÔºó£¬ÈËÃÇ·¢ÏÖServletÀàµÄ±àдÊǷdz£·±ËöµÄ£¬Ö÷Òª¼¯ÖÐÔÚ¼¸¸öÎÊÌâÉÏ£ºÊ×ÏÈÓдóÁ¿ÈßÓà´úÂ룬ÕâЩ´úÂëÔÚÿ¸öservletÀàÖж ......