后台有个List数组taskName,我在前台怎么用<logic:iterate>的嵌套循环把List数组中的数据循环出来啊!!

解决方案 »

  1.   

    这个标记用于循环
    下面是一个例子
     <logic:iterate id="prinfo"--session中javaBean的别名
      name="c_prinfo"--session中集合的名称
      scope="session"> --代表这个集合从session中获得
        <tr> 
        <td><bean:write name="prinfo" property="prname" /></td>
        </logic:iterate>
        其中bean:write的说明:
        name:与iterate中的id值对应,。
       property:代码这个bean的属性名,这将获得这个属性的值。 
      

  2.   

    <%
     HashMap months=new HashMap();
     months.put("Jan.","January");
     months.put("Feb.","February");
     request.setAttribute("months",months);
    %>
    <logic:iterate id="element" name="months">
    <bean:write name="element" property="key"/>
    <bean:write name="element" property="value"/>
    </logic:iterate>
    <%
     Vector animals=new Vector();
     animals.addElement("Dog");
     animals.addElement("Cat");
     animals.addElement("Bird");
     animals.addElement("Chick");
     request.setAttribute("Animals", animals);
    %>
    <logic:iterate id="element" name="Animals">
       <bean:write name="element"/><BR>
    </logic:iterate><p>
    给你这两段程序看,应该就差不多该明白了吧
      

  3.   

    楼上的例子是不是ACCP的啊,经典啊。
      

  4.   

    1楼没错啊,如果List中不是对象的话,这样用<logic:iterate id="prinfo"  name="c_prinfo"--session中集合的名称
      scope="session"> --代表这个集合从session中获得
        <tr> 
        <td><bean:write name="prinfo" /></td>
        </logic:iterate>
      

  5.   

    我的是list数组,数组中每个元素是一个List对象,每个list对象里存放了多个javabean,应该怎么循环啊!请指教!
      

  6.   

    这不简单吗,两重循环
     <logic:iterate id="prinfo" name="c_prinfo"  scope="session">
        
        <logic:iterate id="aaBean" name="prinfo">
           <bean:write name="aaBean" property="prname" />
        </logic:iterate></logic:iterate>设置id的作用就是方便嵌套在里面使用的
      

  7.   

    一楼对ID的理解明显不对,id是用来标识检索出的元素的!