0

クラスファイルにデータベースからのDBクエリがあります:

List srActionList = hibernate_session.createQuery("from SrActionModal where srReportShow = 'Y' order by actDesc").list();

ArrayList dataResultList = new ArrayList();
SrActionModal status = new SrActionModal();

for (int i = 0; i < srActionList.size(); i++) {
    status = (SrActionModal) srActionList.get(i);
    status.setActDesc(status.getActDesc());
    dataResultList.add(status);
}
session.setAttribute("srActionList", dataResultList); 

そして、srActionList属性をテーブルに表示したいと思います。現在、私の出力は以下のようです。

    <logic:iterate id="list" name="srActionList">
 <html:multibox property="selectedAction">
    <bean:write name="list" property='code'/>
 </html:multibox>
 <bean:write name="list" property='actDesc'/>
    </logic:iterate>

私の質問は、より良い配置のために結果をテーブルに配置する方法ですか? 1 行あたりの制限列は 2 です。resultsize が 10 の場合、1 行あたり 2 列を含む 5 行になります。

    <table>
     <tr> 
         <td>list 1</td> <td>list 2</td>
     </tr>
     <tr> 
         <td>list 3</td> <td>list 4</td>
     </tr>
    </table>
4

1 に答える 1

0

indexId 属性をページ コンテキスト変数に取得し、2 で割り切れるかどうかをテストできます。次に、奇数の値に TR タグを挿入し、偶数の値に TR タグを挿入します。このようなもの:

   <table>
   <logic:iterate id="list" name="srActionList" indexId="index">
      <% Integer index = (Integer) pageContext.getAttribute("index");
      /* If not divisible by 2 then insert a table row marker */
      if (index.intValue() % 2 == 1) { %>
      <tr>
      <% } %>
      <td>
         <html:multibox property="selectedAction">
         <bean:write name="list" property='code'/>
            </html:multibox>
         <bean:write name="list" property='actDesc'/>
      </td>
      <% Integer index = (Integer) pageContext.getAttribute("index");
      /* If divisible by 2 then insert a table row end marker */
      if (index.intValue() % 2 == 0) { %>
      </tr>
      <% } %>
   </logic:iterate>
   </table>
于 2013-03-26T05:00:03.430 に答える