Cannot create iterator for this collection怎么解决

zzpmaster 2008-02-15 10:14:56
action中:
replyList = this.replyDAO.showReplyList(topicId, lineSize, currentPage);
public List showReplyList(int topicId, int lineSize, int currentPage) throws Exception {
String hql = "FROM TReply AS tr WHERE tr.TTopic=?";
Query query = super.getSession().createQuery(hql);
query.setInteger(0,topicId);
query.setFirstResult((currentPage-1)*lineSize);
query.setMaxResults(lineSize);
List list = query.list();
return list;
}
request.setAttribute("replyList", replyList);
在jsp用struts标签
<logic:present name="replyList" scope="request">
<logic:iterate id="reply" name="replyList" scope="request">
${repUsrID.repContent}
<logic:iterate id="repUsrID" name="reply" property="TUser">
${repUsrID.usrId} //User表中的字段
${repUsrID.usrTopic }
</logic:iterate>
</logic:iterate>
</logic:present>
hibernate的映射文件
public class TReply implements java.io.Serializable {
private Integer repId;
private TTopic TTopic; //外键--对应topic表
private TUser TUser; //外键--对应user 表
private String repContent;
private Date repTime;
private String repIp;
}

为什么在遍历用户信息的时候包 Cannot create iterator for this collection,是我遍历用户的时候写错了么,请朋友们帮我看看哦,先谢谢大家
...全文
295 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
zzpmaster 2008-02-18
  • 打赏
  • 举报
回复
!!
zzpmaster 2008-02-17
  • 打赏
  • 举报
回复
没人知道么,在线等
zzpmaster 2008-02-17
  • 打赏
  • 举报
回复
关键是我想取TReply表中TUser属性,TUser是外键,还的遍历出来user表的信息

顶顶
K_pax 2008-02-16
  • 打赏
  • 举报
回复
分页操作:
<logic:iterate id="reply" name="replyList" scope="request">
${repUsrID.repContent}
/*
<logic:iterate id="repUsrID" name="reply" property="TUser">
${repUsrID.usrId} //User表中的字段
${repUsrID.usrTopic }
</logic:iterate>
这一部分是错误的,要想取得reply中的值应该用<bean:write name="reply" property="TReply中的属性名称" />
这里面不能再遍历了,它是从List中取出的TReply对象,不是集合
还有就是放到request中很有可能在页面跳转时由于request生命周期问题,而使数据销毁
*/
</logic:iterate>
</logic:present>
yami251139 2008-02-16
  • 打赏
  • 举报
回复
jsp里面只寫屬性
把遍歷放到action里面把。。。這樣你拿到了list以后不容易出錯
zzpmaster 2008-02-15
  • 打赏
  • 举报
回复
自己顶一下,希望大家帮帮忙
zzpmaster 2008-02-15
  • 打赏
  • 举报
回复
自己先顶一下,希望大家帮帮忙。

62,623

社区成员

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

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