Springmvc和velocity使用的公用后台分页

时间:2022-11-15 12:06:45

Springmvc和velocity使用的公用后台分页

类别                    [选择一个类别或键入一个新类别]

Springmvc和velocity使用的公用后台分页

样式:

使用到的辅助类代码:

1.        import java.io.Serializable;

2.        import java.lang.reflect.Method;

3.        import java.util.HashMap;

4.        import java.util.Map;

5.

6.        public 开始). */

90.         开始). */

80.         页

175.        页,如果总页数小于等于5页

177.           条");

17.                 pagein(userAppeal,totalCount,10);小于等于$bean.pageCount的数值');

11.                    $("小于等于$bean.pageCount的数值');

16.                    $("#pageNoInput").val('');

17.                    //goPage($bean.pageCount);

18.                 };

19.                 var reg = /^\d+$/;

20.                 if(pageNo!=''&&!reg.test(pageNo))

21.                 {

22.                   alert('输入的页码数必须为整数');

23.                   $("#pageNoInput").val('');

24.                  // goPage(${bean.firstPage});

25.                 }

26.

27.              };

28.              var goPage = function(toPageNo){

29.                 var form = '<form id="page_form" method="post" action="$!{actionUrl}">';

30.                 form += '<input id="pageNo" name="pageNo" type="hidden" value="'+toPageNo+'" />';

31.                 #if($bean.paramBeans)

32.                    #foreach($paramBean in $bean.paramBeans)

33.                       form += '<input type="hidden" class="ios" name="$!paramBean.name" value="$!paramBean.value" />';

34.                    #end

35.                 #end

36.                 form += "</form>";

37.                 jQuery("body").append(form);

38.                 var pageForm = jQuery("#page_form");

39.                 pageForm.submit();

40.              };

41.

42.           </script>

43.           <style>a{text-decoration:none;color:#2D86F2}a:hover {color:blue} </style>

44.

45.     <nav class="pager mt25 ng-scope">

46.         <div class="pager-jump">

47.             第 <input type="text" style="height: 25px;" value="$bean.pageNo" id="pageNoInput" onblur='pagevmGoUrl()' name="pageNoInput" class="form-control"> / $bean.pageCount页

48.          <span style="color:#2D86F2;margin-left:5px;" aria-label="prevPager">跳转</span>

49.        </div>

50.         <ul class="pagination pagination-sm">

51.         ## --------------------------首页---------------

52.             #if ($bean.firstPage != $bean.pageNo)

53.           <li>

54.                 <a href='javascript:void(0)' onclick="goPage($bean.firstPage)" aria-label="prevPager">

55.                     <span aria-hidden="true">&lt;&lt;</span>

56.                 </a>

57.             </li>

58.           #end

59.           #if ($bean.firstPage == $bean.pageNo)

60.           <li class="disabled">

61.                 <a href='javascript:void(0)' disabled = 'true' aria-label="prevPager">

62.                     <span aria-hidden="true">&lt;&lt;</span>

63.                 </a>

64.             </li>

65.           #end

66.        ## --------------------------上一页----------

67.           #if ($bean.prevPage > 0)

68.           <li>

69.                <a href='javascript:void(0)' onclick="goPage($bean.prevPage)" aria-label="prev">

70.                     <span aria-hidden="true">&lt;</span>

71.                 </a>

72.             </li>

73.             #end

74.             #if ($bean.prevPage <= 0)

75.              <li class="disabled">

76.                 <a href='javascript:void(0)' disabled = 'true' aria-label="prev">

77.                     <span aria-hidden="true">&lt;</span>

78.                 </a>

79.             </li>

80.            #end

81.

82.

83.             ## ##############################################

84.             #if($bean.listNum.size() !=0 )

85.                #foreach($num in $bean.listNum)

86.                 #if($bean.pageNo == $num)

87.                  <li class="active"><a href='javascript:void(0)' onclick="goPage($!num)" class = "pageNoA">$!num</a></li>

88.                 #else

89.                  <li><a href='javascript:void(0)' onclick="goPage($!num)" class = "pageNoA">$!num</a></li>

90.                 #end

91.                #end

92.           #else

93.           <li class="active"><a href="#">1</a></li>

94.             <li><a href="#">2</a></li>

95.             <li><a href="#">3</a></li>

96.             <li><a href="#">4</a></li>

97.             <li><a href="#">5</a></li>

98.             <li>

99.           #end

100.         ## #################################################

101.         ## ---------------下一页------------------------------------

102.         #if ($bean.nextPage > 0)

103.          <li>

104.             <a href='javascript:void(0)' onclick="goPage($bean.nextPage)" aria-label="next">

105.                 <span aria-hidden="true">&gt;</span>

106.             </a>

107.         </li>

108.         #end

109.         #if($bean.nextPage < 0)

110.         <li class="disabled">

111.             <a href='javascript:void(0)' disabled = 'true' aria-label="next">

112.                 <span aria-hidden="true">&gt;</span>

113.             </a>

114.         </li>

115.         #end

116.         ## --------------------最后一页----------------------------------------

117.         #if ($bean.lastPage != $bean.pageNo )

118.          <li>

119.             <a href='javascript:void(0)' onclick="goPage($bean.lastPage)" aria-label="nextPager">

120.                 <span aria-hidden="true">&gt;&gt;</span>

121.             </a>

122.         </li>

123.         #end

124.         #if($bean.pageNo == $bean.pageCount)

125.         <li class="disabled">

126.             <a href='javascript:void(0)' disabled = 'true' aria-label="nextPager">

127.                 <span aria-hidden="true">&gt;&gt;</span>

128.             </a>

129.         </li>

130.         #end

131.         ## -------------------------总页数----------------------------------------

132.

133.     </ul>

134. </nav>

将page.vm引入html

1.        #parse("/page.vm")

总结:

后台将第一页,最后一页,总页数,算出来.要显示的1,2,3页数放在一个list中。

将他们发到页面上去,如果是条件查询,就在页面是会生成一个form表单,当他点击第n页的时候会触发submit提交。再次将条件带过去,如此来回传输

pasting