使用<logic:iterate/>标签:1.在Action中将数据组织到一个Collection, Enumerator,Iterator, Map或者Array类型的对象,根据你程序的需要将这个对象存入request或session甚至application中。例如:
必须现有一个Bean
 public class infoBean {
  private String name;
  private String id;
  public String getName() {
    return name;
  }
  public void setName(String name) {
    this.name = name;
  }
  public String getId() {
    return id;
  }
  public void setId(String id) {
    this.id = id;
  }
}
然后在Action中存入Array
public ActionForward execute(ActionMapping actionMapping,
                               ActionForm actionForm,
                               HttpServletRequest httpServletRequest,
                               HttpServletResponse httpServletResponse) {
    //.......
    
    java.util.List list = new java.util.ArrayList();
    
    for(int i=0;i<10;i++){
      infoBean a = new infoBean();
      a.setId(...);
      a.setName(...);
      list.add(a);
    }
    
    httpServletRequest.setAttribute("list",list);
    
    ... 
}2. 在Action所Forward的Jsp页面:
<table>
<logic:iterate id="aRow" name="list">
  <tr>
    <td><bean:write name="aRow" property="id"/></td>
    <td><bean:write name="aRow" property="name"/></td>
  </tr>
</logic:iterate>
</table>

解决方案 »

  1.   

    呵呵,此问题已经在楼上兄弟的指导下解决了,多谢啦!现在正在研究J2EE,以后想多跟你交流交流QQ:9661505
    信箱:[email protected]
      

  2.   

    谢谢xiaoxi777(小溪) 的回答!
      

  3.   

    不好意思,借贵贴问个问题:
    我如果不用一般的bean而是用formbean,而且frombean有2个数组或者ArrayList(name1,name2)的属性,我在jsp里面画table时应该怎么做呢?
    table样式:
    name1      name2
    value11    value21
    value12    value22
    ...谢谢了。
      

  4.   

    我开了一个问题,请大家到这里帮帮忙。
    http://community.csdn.net/Expert/topic/3375/3375336.xml?temp=.3042566
    谢谢了。