huobao89 2008-10-10 15:53
浏览 217
已采纳

Pager-taglib分页 export地方

用 Pager-taglib做分页。 在action 里有参数 开始索引号startIndex 一共数据个数total。
在用Pager-taglib 时,页面 按 下一页,没有反应。总是显示第一页的数据。
我不明白的是,怎么把startindex值传到 叶面 上

代码
maxPageItems="7" maxIndexPages="10"
export="pageOffset=startIndex,pageNumber=pageSize" >

我在底层用的是DetachedCriteria做的查询。
这个就是在网上一艘一大把的那个分页。
http://www.iteye.com/topic/14657?page=1

在struts2的action 里能得到 这些参数
ps.getItems()得到已分页好的结果集
ps.getIndexes()得到分页索引的数组
ps.getTotalCount()得到总结果数
ps.getStartIndex()当前分页索引
ps.getNextIndex()下一页索引
ps.getPreviousIndex()上一页索引

就是export="pageOffset=startIndex,pageNumber=pageSize" 这个地方我不知道怎么写。
我这么些,报错 pg:pager TagExtraInfo isValid() == false

help help

[b]问题补充:[/b]
ThinkingInAll 赫赫谢谢你呀。
最近休息了,没有上网。
不是我小气,是因为我现在没有几分呀。
我现在是0分。
那3分还是系统给的分。 穷呀。
用s:property 能得到startIndex,pageSize的值
但是,pageOffset=startIndex,pageNumber=pageSize
是验证错误pg:pager TagExtraInfo isValid() == false

用startIndex=pageOffset,pageSize=pageNumber

没有报错,但是虽然pager.offset在变,
但是还显示第一页。

[b]问题补充:[/b]
ThinkingInAll 谢谢你的帮助。

我查询了,就是startIndex=pageOffset,pageSize=pageNumber
这个地方有问题。
那个分页是dao层是根据startIndex的值来取分页的内容的。
可是,现在,按下一页pager.offset变了,
但是startIndex没有变,还是0,
就是说分页和逻辑部分没有联系起来。
看了pager的文档,能和逻辑部分联系的就是
export了。
不知道该怎么弄。也许还有别的参数??
help help
[b]问题补充:[/b]
赫赫 谢谢你呀ThinkingInAll

dao 层就是robinn写的那个。
http://www.iteye.com/topic/14657?page=1

action
查询
public String pager() throws Exception{
DetachedCriteria detachedCriteria = DetachedCriteria.forClass(Goods.class);
// 查询条件
if (null != getCategory()) {
detachedCriteria.add(Restrictions.in(("category"), getCategory()))
.add(Restrictions.between(("price"), getMinPrice(),getMaxPrice()))
.addOrder(Order.asc("price"));
} else {
detachedCriteria.add(Restrictions.between(("price"), getMinPrice(),getMaxPrice()))
.addOrder(Order.asc("price"));
}
//查询

ps = goodsManager.findpageByCriteria(detachedCriteria, pageSize,startIndex);
previousIndex = ps.getPreviousIndex();
nextIndex = ps.getNextIndex();
startIndex = ps.getStartIndex();
totalCount = ps.getTotalCount();

分页

public String pagerPage() throws Exception{
sessionMap = ActionContext.getContext().getSession();
DetachedCriteria detachedCriteria = (DetachedCriteria)sessionMap.get("detachedCriteriaList");
ps = goodsManager.findpageByCriteria(detachedCriteria, pageSize, startIndex);
totalCount = ps.getTotalCount();
startIndex = ps.getStartIndex();
return SUCCESS;
}

jsp

maxPageItems="7" maxIndexPages="10"
export="pageSize=pageOffset,startIndex=pageNumber" scope="request">
pg:index
pg:first
/pg:first
">[ #<%= pageNumber %> Skip ]
/pg:skip
pg:prev
/pg:prev
pg:pages
/pg:pages
pg:next
/pg:next
">[ Skip #<%= pageNumber %> ]
/pg:skip
pg:last
/pg:last
/pg:index
/pg:pager

谢谢了。
查询url http://localhost:8080/ssh222/pager.action
分页url http://localhost:8080/ssh222/pagerPage.action?pager.offset=7
还有,如果不用pager-taglib做分页,我做上一页,下一页没有问题。我那时是用startIndex来做的。也就说,只要 pageOffset和startIndex 有联系,就没有问题。
还有,这样写pageSize=pageOffset,startIndex=pageNumber不报错。这样写pageOffset=startIndex,pageNumber=pageSize报错

麻烦你了。

  • 写回答

4条回答 默认 最新

  • tantenis 2008-10-14 17:15
    关注

    我忘记了,这个好像不能改变量pager.offset

    我以前做的话就是写一个pager类,然后注入到action里面

    pager类里面有offset,num,这种参数保存分页的信息

    你也可以像我这样做,或者写一个map的变量名为pager
    然后把startindex放到pager.offset里面去就行了

    如果想直接用startindex这种参数作为分页信息也可以,改一下源代码就行了

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(3条)

报告相同问题?

悬赏问题

  • ¥15 运筹学排序问题中的在线排序
  • ¥15 关于docker部署flink集成hadoop的yarn,请教个问题 flink启动yarn-session.sh连不上hadoop,这个整了好几天一直不行,求帮忙看一下怎么解决
  • ¥30 求一段fortran代码用IVF编译运行的结果
  • ¥15 深度学习根据CNN网络模型,搭建BP模型并训练MNIST数据集
  • ¥15 C++ 头文件/宏冲突问题解决
  • ¥15 用comsol模拟大气湍流通过底部加热(温度不同)的腔体
  • ¥50 安卓adb backup备份子用户应用数据失败
  • ¥20 有人能用聚类分析帮我分析一下文本内容嘛
  • ¥30 python代码,帮调试,帮帮忙吧
  • ¥15 #MATLAB仿真#车辆换道路径规划