严格控制在Controll里
jsp里用<bean:write name="" property=""/>体现
前面还得加上<logic:iterate name="" property=""/>

解决方案 »

  1.   

    to : dragon119(dragon119) ( ) 
    说得再详细一点好吗?我也想知道 !
      

  2.   

    最好将resultSet封装为bean集合类,这样就可能能过<logic:iterate name="yourCollection" id="curObjId"/>
      <bean:write name="curObjId" property="yourProperty"/>
    </logic:iterate>
      

  3.   

    我一般是把每条记录当成一个 DataObject 
    然后 通过 rs 的赋值 。
    最后把那些 DataObject 依次放入 Vector 里。
    然后在jsp上:
    <logic:present name="yourActionFormName" property="yourVectorName">
    <logic:iterate id="aDataName" name="yourActionFormName" property="yourVectorName">
    <bean:write id="aDataName" property="value"/>
    </logic:iterate>
    </logic:present>
    不知道是否对你有帮助?
      

  4.   

    在网上查到的一个较好的解决方案:As it happens, though, I just checked in a change in commons-beanutils
    that can be used for this purpose, if you're using Struts 1.1.
    Basically, there's now a really simple way to copy the contents of a
    ResultSet into a list of DynaBeans. This really is a *copy* operation,
    so you have to pay some performance and memory cost, but it lets you
    pass the data without having to create custom beans, and without leaving
    the ResultSet open.You'll need to grab a very recent nightly build of commons-beanutils
    from:
    http://jakarta.apache.org/builds/jakarta-commons/nightly/commons-beanuti
    lsand replace your commons-beanutils.jar file if you want to try this.> Please include the .java and .jsp code.
    >In your Java code, you'd do something like this:Connection conn = ...; // Get connection from the pool
    Statement stmt = conn.createStatement();
    ResultSet rs = stmt.executeQuery("select custid, name from
    customers");
    RowSetDynaClass rsdc = new RowSetDynaClass(rs);
    rs.close();
    stmt.close();
    ... return connection to the pool ...
    request.setAttribute("custoemrs", rsdc.getRows());In your JSP page, treat this List of DynaBeans like you would any other
    collection of beans, because all the Struts tags know how to deal with
    DynaBeans.<table>
    <tr>
    <th>Customer ID</th>
    <th>Customer Name</th>
    </tr>
    <logic:iterate name="customers" id="customer">
    <tr>
    <td><bean:write name="customer" property="custid"/></td>
    <td><bean:write name="customer" property="name"/></td>
    </tr>
    </logic:iterate>
    </table>See the updated Javadocs for commons-beanutils (included in the binary
    distribution) for class org.apache.commons.beanutils.RowSetDataSource
    for more information about this class.Craig