改成collection的话是另一个异常: javax.servlet.jsp.JspException: Cannot create iterator for this collection
Sometimes you want to iterate over a computed value rather than a bean property. In that case, you can use the collection attribute摘自《struts kick start> 很清楚,如果是一个bean的属性,用name= property=,如果是一个独立的collection类型的bean,用collection=.
那Cannot create iterator for this collection这个异常又代表什么呢
如果是formbean的属性,用name= + property=的方式。如果是独立的bean,用collection=方式。 javax.servlet.jsp.JspException: Cannot create iterator for this collection说明你的原来的对象类型不对,不是前面charlie0895(命)提到的类型。或是内部存储了不可序列化的对象。
类型是对的。Collection result = new ArrayList(); 存储的对象也是可序列化的。都result.add(group). group的类groupDTO都implement了Serializable接口
to serf(): 我发现把<% request.setAttribute("groups",new java.util.ArrayList()); %> 放在<logic:present name="groups">的上面, 反而是用name="groups"不会有异常; 而用collection="groups"就依然有异常Cannot create iterator for this collection 就是不知道为什么在本页set进request就能找到, 在Action里设进request再转到本页就找不到
javax.servlet.jsp.JspException: Cannot create iterator for this collection
In that case, you can use the collection attribute摘自《struts kick start>
很清楚,如果是一个bean的属性,用name= property=,如果是一个独立的collection类型的bean,用collection=.
<logic:iterate id="currentList" name="resultList" indexId="index">
<TR><TD height="20pt" style ="text-align:center" nowrap>
<bean:write name="currentList" property="projectNo"/>
</TD></TR>
</logic:iterate>
</logic>resultList 需要在formbean中定义过,然后给resultList赋值!
我把单独一个collection set进request里,
按书上的说法应该也是可以的啊
javax.servlet.jsp.JspException: Cannot create iterator for this collection说明你的原来的对象类型不对,不是前面charlie0895(命)提到的类型。或是内部存储了不可序列化的对象。
存储的对象也是可序列化的。都result.add(group).
group的类groupDTO都implement了Serializable接口
我发现把<% request.setAttribute("groups",new java.util.ArrayList()); %>
放在<logic:present name="groups">的上面,
反而是用name="groups"不会有异常;
而用collection="groups"就依然有异常Cannot create iterator for this collection
就是不知道为什么在本页set进request就能找到,
在Action里设进request再转到本页就找不到
循环中多个checkbox重名了。
我真不小心。:)