大家帮我看下怎么样用循环怎输入这个信息。

w791918 w791918 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
DAO层代码:
public Map<String, Object> getinfo(String tid)
{
Map<String, Object> map=new HashMap<String, Object>();
String sql="select * from daytopics where tid="+tid;
Result rstResult=excuteQuery(sql,null);
for(int i=0;i<rstResult.getRowCount();i++){
Map row = rstResult.getRows()[i];
map.put("DayTopic", inittopic(row));
}

sql="select * from topictalk where tid="+tid;
Result rst=excuteQuery(sql,null);
for(int i=0;i<rst.getRowCount();i++){
Map r = rst.getRows()[i];
map.put("TopticTalk", initTalk(r));
}
return map;
}


servlet代码:

request.setCharacterEncoding("utf-8");
String op=request.getParameter("op");
String tid=request.getParameter("Tid");
String url="";
if(op.equalsIgnoreCase("show_Topic")){
Map<String, Object> map=new DayTopicDao().getinfo(tid);
//if(map.containsKey("1"))
//{
DayTopic da=(DayTopic )map.get("DayTopic");
//}else if (map.containsKey("2")) {
TopticTalk dt=(TopticTalk)map.get("TopticTalk");
//}
request.setAttribute("topic",da);
request.setAttribute("topictalk",dt);
url="/show_Topic.jsp";
}
request.getRequestDispatcher(url).forward(request, response);


JSP页面代码:

<c:set var="talk" scope="page" value="${requestScope.topictalk}"></c:set>
<tr>
<td width="100" height="50" align="center" style="border-bottom: dashed #B5B9CA 1px;"><img src="images/char.gif" style="border:#cccccc 1px solid;"/><br />
<br />
${talk.Comauthor}</td>
<td align="left" class="top01" style="border-bottom: dashed #B5B9CA 1px;">${talk.tpcomment }<br />
<span style="font-size:11px;color:#999999;height:30px;line-height:30px;">${talk.tptime }</span>
</td>
</tr>
<tr>
我一用forEach循环就报错,报错信息为:javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in <forEach>
请教各位我怎么样才能循环输出啊,求具体代码,本人菜鸟哦,勿笑啊
...全文

相关推荐

评论 1
收藏 已收藏
分享
返回顶部
w791918
Web 开发 81,107 成员 341,720 内容