List<TextBean> list = new ArrayList<TextBean>();
for(....) {
TextBean textBean = new TextBean();
......
list.add(textBean)
}
request.setAttribute("textBean", textBean);
public class TextBean {
  private String a ;
  .....
  get()...
  set()...
}我只会这么写<% 
ArrayList list = <ArrayList>request.getAttribute("textBean", textBean);
for(int i=0;i<list.size();i++) {
   TextBean textBean = (TextBean)list.get(i);
}
%>
请问下:1.struts该如何怎么写
下面的写法报错:<logic:iterate id="str" name="textBean" scope="request">
     <logic:iterate id="ref" name="str" property="a">
         <bean:write name="ref"/>
     </logic:iterate>
  </logic:iterate>报错:Cannot create iterator for this collection
 2.jstl中又该怎么写?

解决方案 »

  1.   

    1、struts标签:    <logic:iterate id="str" name="textBean" scope="request">
             <bean:write name="str" property="a"/>
        </logic:iterate>2、JSTL:    <c:forEach items="${requestScope.textBean}" var="str">
              <c:out value="${str.a}"/>
        </c:forEach>