日期:2014-05-20  浏览次数:20825 次

救助ssh中的Don't know how to iterate over supplied "items" in <forEach>的问题
index.jsp页面的一段代码是  
 <c:if test="${!empty orgs}">
  <c:forEach items="${orgs}" var="org">
<tr bgcolor="#EFF3F7" class="TableBody1" onmouseover="this.bgColor = '#DEE7FF';" onmouseout="this.bgColor='#EFF3F7';">
<td align="center" vAlign="center">${org.id }</td>
<td align="center" vAlign="center"><a href="org.do?parentid=${org.id}">${org.name }</a></td>
<td align="center" vAlign="center">${org.sn }</td>
<td align="center" vAlign="center">${org.parent.name }</td>
<td align="center" vAlign="center"><a href="#" onclick="del('person.do?method=del&id=${org.id }');">删除</a></td>
  </tr>
  </c:forEach>
</c:if>
  <!-- 在列表数据为空的时候,要显示的提示信息 -->
<c:if test="${empty orgs}">
<tr>
<td colspan="7" align="center" bgcolor="#EFF3F7" class="TableBody1" onmouseover="this.bgColor = '#DEE7FF';" onmouseout="this.bgColor='#EFF3F7';">
没有找到相应的记录
</td>
</tr>
</c:if>
我action的代码:
protected ActionForward unspecified(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response) throws Exception {
OrgActionForm oaf=(OrgActionForm)form;
request.setAttribute("orgs",orgManager.findOrg(0));
return mapping.findForward("index");
}
业务逻辑的实现类:
public List findOrgs(int parentid) {
if(parentid==0){
return getHibernateTemplate().find("from Orgnization o where o.parent.id is null");
}
return getHibernateTemplate().find("from Orgnization o where o.parent.id = ?", parentid);
}
我想问的是items不是可以用List类型不知道我那里错了.希望个位帮帮忙谢谢.
下面是错误
严重: Servlet.service() for servlet jsp threw exception
javax.servlet.jsp.JspTagException: Don't know how to iterate over supplied "items" in &lt;forEach&gt;
at org.apache.taglibs.standard.tag.common.core.ForEachSupport.toForEachIterator(ForEachSupport.java:255)
at org.apache.taglibs.standard.tag.common.core.ForEachSupport.supportedTypeForEachIterator(ForEachSupport.java:219)
at org.apache.taglibs.standard.tag.common.core.ForEachSupport.prepare(ForEachSupport.java:137)
at javax.servlet.jsp.jstl.core.LoopTagSupport.doStartTag(LoopTagSupport.java:227)
at org.apache.jsp.org.index_jsp._jspx_meth_c_005fforEach_005f0(index_jsp.java:221)
at org.apache.jsp.org.index_jsp._jspx_meth_c_005fif_005f0(index_jsp.java:190)
at org.apache.jsp.org.index_jsp._jspService(index_jsp.java:140)
at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:393)
at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:320)
at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:266)
at javax.servlet.http.HttpServlet.service(HttpServlet.java:803)
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:654)
at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:445)
at org.apache.catalina.core.ApplicationDispatcher.doForward(ApplicationDispatcher.java:379)