pager-taglib分页 求救!!!

renziliu 2007-10-28 09:42:24
用pager-taglib 做jsp分页,在第一次收到从action来的结果集,正常。换页后就不显示了,应该是结果集超出了范围,不知为什么?请教各位,先谢谢了。
相关代码片断如下:

action里传结果集的:
Session session = SessionFactory.getSession();
Transaction tx = session.beginTransaction();
Query q = session.createQuery("from Student as s where s.name='"
+ csForm.getSname() + "'" + " and s.entertime >= "+ dtime + " and s.entertime <= " + ntime);
List lq = q.list();
if(lq.isEmpty()){
errors.add("error.findnull", new ActionError("error.findnull"));
saveErrors(request, errors);
return mapping.findForward("error");
}
request.setAttribute("sid", sid);
request.setAttribute("SLIST", lq);//重点在这儿

return new ActionForward("/list.jsp");

jsp部分:



<pg:pager url="slist.do" maxPageItems="4" maxIndexPages="3"
export="currentPageNumber=pageNumber" >
<table width="95%" cellspacing="1" cellpadding="0" align="center">
<tr class="tdheader">
<th width="10%" align="center"> 
</th>

<th width="10%" align="center">
学号
</th>
<th width="10%" align="center">
姓名
</th>
<th width="10%" align="center">
性别
</th>
<th width="10%" align="center">
年龄
</th>
<th width="10%" align="center">
所在班级
</th>
<th width="10%" align="center">
入学时间
</th>
<th width="15%" align="center">
家庭住址
</th>
<th width="15%" align="center">
联系电话
</th>
</tr>
<c:forEach var='sd' items="${SLIST}">
<pg:item>

<tr>
<td width="10%"> 
</td>

<td width="10%">
<font color="#008200"><c:out value='${sd.studentnumber}' /> </font>
</td>
<td width="10%">
<font color="#008200"><c:out value='${sd.name}' /> </font>
</td>
<td width="10%">
<font color="#008200"> <c:out value='${sd.sex}' /></font>
</td>
<td width="10%">
<font color="#008200"><c:out value='${sd.age}' /> </font>
</td>
<td width="10%">
<font color="#008200"><c:out value='${sd.studentclass}' /> </font>
</td>
<td width="10%">
<%
/*
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
Date d = sd.getEntertime();
String ss ="";
if(null != d){
StringBuffer sb = new StringBuffer();
sdf.format(d,sb,new FieldPosition(0));
ss =(sb.toString());
}
*/

%>
<font color="#008200">  </font>
</td>
<td width="15%">
<font color="#008200"><c:out value='${sd.address}' /> </font>
</td>
<td width="15%">
<font color="#008200"><c:out value='${sd.telephone}' /></font>
</td>



</tr>
</pg:item>

</c:forEach>
</table>
<TABLE width="80%" border="0">
<TR><TD> </TD></TR>
<TR align="center">
<TD>
<pg:index>

<pg:prev><a href="<%= pageUrl%>">[<<Prev]</a></pg:prev>

<pg:pages><a href="<%= pageUrl %>"><%= pageNumber %></a></pg:pages>

<pg:next><a href="<%= pageUrl%>">[Next>>]</a></pg:next>

</pg:index>
</TD>
</TR>
<TR><TD> </TD></TR>
</TABLE>
</pg:pager>



其中slist.do 在structs-config.xml中

<action path="/slist"
parameter="/list.jsp"
type="org.apache.struts.actions.ForwardAction" />
...全文
136 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
renziliu 2007-10-31
  • 打赏
  • 举报
回复
不知为什么?今天试了一下,正常了.一头雾水.... 看来还得仔细看下源吗.
tubage408 2007-10-28
  • 打赏
  • 举报
回复
pager-taglib 没用过,用过display tag,也出现过这种情况。应该是得到的list的问题,你把list的大小打出来看看呀

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧