1) session.setAttribute("list", list);在jsp的<html:form>对应的action中设置.
2) list 可以是list,String[]均可
3) session 写过,另一个没试过。
4) 不明白什么意思

解决方案 »

  1.   

    参考:The tag then loops over each member of the collection (which can either be an array, a Collection, Enumeration, Iterator, or Map), setting the id to the element and evaluating its contents.
      

  2.   

    一般情况下</logic:iterate>提交到actionForm到Action的。
      

  3.   

    1) session.setAttribute("list", list);在jsp的<html:form>对应的action中设置.在action的execute里设置session.setAttribute("list", list);?2>一般情况下</logic:iterate>提交到actionForm到Action的?我更不明白了,请问下,如果你想在一个独立的页面里显示新闻列表,该怎么做?不能直接请求news.jsp吗? 难道还要为这个页面写一个action?
      

  4.   

    谢谢 studyday(好好学习天天向上)
      

  5.   

    1) session.setAttribute("list", list);在jsp的<html:form>对应的action中设置.在action的execute里设置session.setAttribute("list", list);?是的,在request中得到getSession,然后再session.setAttribute("list", list);2) 2>一般情况下</logic:iterate>提交到actionForm到Action的?我更不明白了,请问下,如果你想在一个独立的页面里显示新闻列表,该怎么做?不能直接请求news.jsp吗? 难道还要为这个页面写一个action?如果你的<logic:iterate>只是用来作结果输出的话,那么forward 到这个页面来就应该可以了。请参考:
    The iterate tag is probably the most complicated one in the logic tag library, but also one of the most useful. At its heart, it's pretty simple. You specify a collection with the name or name and property attribute, and specify a bean to hold the individual members of the collection in id. The tag then loops over each member of the collection (which can either be an array, a Collection, Enumeration, Iterator, or Map), setting the id to the element and evaluating its contents.主要是:You specify a collection ,property attribute,and specify a bean 
    以上三个是必须的,如果你的</logic:iterate>需要提交处理,但如果不处理就没有必要了。愚见,呵呵,仅供参考!!!
      

  6.   

    <logic:iterate>只是用来作结果输出?
    哦,原来这样,谢谢studyday(好好学习天天向上) 如果我不是做结果输出,而是事先在前台jsp页面显示数据用什么标签?
    也就是用不到action的页面,该怎么办?
      

  7.   

    <logic:iterate name="optionsForm" property="fruit3" id="fruit">
        <bean:write name="fruit" />
    </logic:iterate>fruito 为一个集合.
      

  8.   

    那要看你的form是怎么写的了
    <html:form action="/aa/bb"   method="post">
    aa/bb和你转发的action对应,在xml通过<action path="aa/bb" name="ListForm"../>
    及ListForm对应的你的ActionForm(aaForm extends ActionForm)
    <logic:iterate id="userList" name="aaForm" type="aa.bb.cc.aaForm">
      <tr>
        <td><bean:write name="userList" property="username"/></td>
        <td><bean:write name="userList" property="password"/></td>
        <td><bean:write name="userList" property="email"/></td>
      </tr>
    </logic:iterate>name,type property都注意大小写了,看你的get set 怎么写了
    如果Action ActionForm <html:form 这些没对应上,大小写没对,挂的我也没办法了:>
      

  9.   

    to zhonghua2003(爱我中华) 看不懂你的代码to lulin444(麟麟) 
    <logic:iterate id="userList" name="aaForm" type="aa.bb.cc.aaForm">
    aaForm与aaForm extends ActionForm名字对应?还是与Action对应?我都搞胡了,不是在Action的execute方法里执行session.setAttribute("list", list);吗?谢谢两位
      

  10.   

    你用hibernate.这个我没有用过.一般是这样的.
    <logic:iterate id="userList" name="list" type="oa.hibernate.po.User" scope="request">
      <tr>
        <td><bean:write name="userList" property="username"/></td>
        <td><bean:write name="userList" property="password"/></td>
        <td><bean:write name="userList" property="email"/></td>
      </tr>
    </logic:iterate>userList是你在action里面定义的ActionForm
    list是你从Action里面所存从库里面查出来的记录.一个ArrayList
    如上面.
    userList.setUsername(rs.getString("name"));
    list.add(userList);
    excute方法里面:
    reqeust.setAttribute("list", list);
    在jsp页面上如你所列出来的就可以调用了.
      

  11.   

    <struts-config>
        <form-beans>
    <form-bean name="nameForm"   type="com.my.StForm"/>
    </form-beans>    <action-mappings>
    <action path="/aa/bb"
             type="com.my.StAction"
            name="nameForm"
            scope="request"         
            parameter="operate"
            unknown="false"
            validate="false">
            <forward name="success" path="aa"/>
           
     </action>
    </action-mappings>
    </struts-config><html:form action="/aa/bb"   method="post"><logic:iterate id="userList" name="StForm" type="com.my.StForm">
      <tr>
        <td><bean:write name="userList" property="username"/></td>
        <td><bean:write name="userList" property="password"/></td>
        <td><bean:write name="userList" property="email"/></td>
      </tr>
    </logic:iterate>
    </html:form>
      

  12.   

    http://community.csdn.net/Expert/TopicView.asp?id=3484308我还是没有想通,解决问题一起给分
      

  13.   

    不是StForm也行,还可以是StAction里的容器,比如是在StAction里往session里放了个Array,HashTable等等
      

  14.   

    从这句“并非从表单转过来的,用户是直接请求”来分析,应该是指在请求地址后用?带上参数吧?如果不是,我也不明白是如何直接请求,如果是则用如下方法:
    1、为了不在JSP中带许多《% %》,所以用户的请求还是发给Action处理;
    2、在Action中用getSimpleProperty函数读取数据,例如:
            String username = (String) PropertyUtils.getSimpleProperty(form,               USERNAME);
            String password = (String) PropertyUtils.getSimpleProperty(form,                PASSWORD);
     把数据收集到list中,再用reqeust.setAttribute("list",list);保存数据。