velocity 分页宏,传参问题
#macro(page $totalCount $start $limit $formId) #set($istart = 0) #set($ilimit = 15) #if($!totalCount == '') a1 #set( $totalCount = 0) #else b1 #set( $totalCount = $number.toNumber( $totalCount)) #end #if($!start == '') a2 #set($start = 1) #else b2 #set($start = $number.toNumber( $start)) #end #if($!limit == '') a3 #set($limit = 15 ) #else b3 #set($limit = $number.toNumber( $limit)) #end ##计算当前页 #set($istart = $start - 1) #set($ilimit = $limit) #set($currentPage = $istart / $limit + 1) #set($pageSize = $limit)##limit即为每页显示的条数 #set($pageSize = $number.toNumber($limit)) #set($offset = 2) ## 计算总页数 #if($totalCount % $pageSize > 0) a4 #set($pageCount = ($totalCount / $pageSize) + 1) #else b4 #set($pageCount = ($totalCount / $pageSize)) #end #set($page = 5)## #set($maxpage = 10) #set($realpages = 1) #if($!totalCount > 0) <div class="page"> #if($page > $pageCount) a5 #set($from = 1) #set($to = $pageCount) #else b5 #set($from = $currentPage - $offset) #set($to = $from + $page - 1) #if($from < 1) #set($from = 1) #set($to = $page) #elseif($to > $pageCount) #set($from = $pageCount - $page + 1) #set($to = $pageCount) #end #end #set($from = $number.toNumber($from)) #set($to = $number.toNumber($to)) #if($currentPage - $offset > 1 && $pageCount > $page) <a href="javascript:void(0);" onclick="pageIndexClick(1,$limit,$totalCount,$formId);" class="first">1 ...</a> #end #if($currentPage > 1) #set($startTemp = ($currentPage - 2) * $limit + 1) <a href="javascript:void(0);" onclick="pageIndexClick($startTemp,$limit,$totalCount,$formId);" class="prev">‹‹</a> #end #foreach($idx in [$from .. $to]) 11111111 #if($idx == $currentPage) <strong>$idx</strong> #else #set($startTemp = ($idx - 1) * $limit + 1) <a href="javascript:void(0);" onclick="pageIndexClick($startTemp,$limit,$totalCount,$formId);">$idx</a> #end #end #if($currentPage < $pageCount) #set($startTemp = $currentPage * $limit + 1) <a href="javascript:void(0);" onclick="pageIndexClick($startTemp,$limit,$totalCount,$formId);" class="next">››</a> #end #if($to <$pageCount) #set($startTemp = ($pageCount - 1) * $limit + 1) <a href="javascript:void(0);" onclick="pageIndexClick($startTemp,$limit,$totalCount,$formId);" class="last">... $!pageCount</a> #end <em>共 $!totalCount 条记录</em> </div> #end #end请问 我调用的时候传参 #page("$!pdt.totalCount",1,15,"no_product_query")是正常的,
但是 #page("$!pdt.totalCount","1","15","no_product_query") 这样传参的话,分页就是
不正常的,具体是
#foreach($idx in [$from .. $to]) 11111111 #if($idx == $currentPage) <strong>$idx</strong> #else #set($startTemp = ($idx - 1) * $limit + 1) <a href="javascript:void(0);" onclick="pageIndexClick($startTemp,$limit,$totalCount,$formId);">$idx</a> #end #end
这个循环里的代码没执行。请问是为什么?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你第二种调用方法传递的是字符串,然后宏里面又做了数学运算,肯定不行啊,必须的传递数值参数
你第二种调用方法传递的是字符串,然后宏里面又做了数学运算,肯定不行啊,必须的传递数值参数