<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<%@ taglib uri="/struts-tags" prefix="struts"  %>
<%@ taglib prefix="sx" uri="/struts-dojo-tags"%> <jsp:include flush="true" page="header.jsp"></jsp:include>
<div class="contentwrap z"> <struts:iterator var="category" value="categorylist">
     <div class="t">
         <table cellspacing="0" cellpadding="0" width="100%">
          <tr>
             <th class="h" colspan="6">
                <a class="closeicon fr" style="cursor:pointer;" onclick="return IndexDeploy('85',0)">
                <img id="img_85" src="images/yellow/index/cate_fold.gif" />
                </a>
                <h2>
                <a  href='<struts:url action="listCategory"/>?categoryfm.id=${ category.id}'  class="cfont">
                ${category.name} 
                </a>
                <c:if test="${category.id != null}">
                <a  href='<struts:url action="initaddBoard"/>?categoryId=${ category.id}'  class="cfont">
               增加版面 
                </a>
                </c:if>
                </h2> 
             </th>
             </tr>
             <tr></tr>
             <tr class="tr2">
                <td width="*" colspan="2" class="tac">论坛</td>
                <td class="tal y_style e" style="width:5%">主题</td>
                <td class="tal y_style e" style="width:5%">文章</td>
                <td class="tal y_style f" style="width:39%">最后发表</td>
                <td class="y_style" style="width:10%">版主</td>
             </tr>
             <tbody id="cate_85" style="display:;">   
              <struts:iterator var="board1" value="category.boards">
                <tr class="tr3 f_one" >
                   <td class="icon tac" width="45">
                    <a href='<struts:url action="listBoard"/>?board.id=${board1.id }'>pic
                    </a>
                    {board1.name }
                   </td>
                   <th>
                     <h3 class="b">
                     <a href='<struts:url action="listBoard"/>?board.id=${board1.id }'>${board1.name }
                    </a>
                     </h3>
                     <br/>
                     <span class="smalltxt gray">${board1.description} </span>
                   </th>
                   <td class="tal y-style e">
                     <span class="f10">${board1.threadCount}
                     </span>
                     <br/>
                   </td>
                   <td class="tal y-style e">
                     <span class="f10">${board1.replyCount}
                     </span>
                      <br/>
                   </td>
                   <th>
                      <c:if test="${board1.lastThread != null}">
                      <a>
                      
                      </a>
                      <br/>
                      <span class="f12">
                      <a> </a>
                      </span>
                      <span class="f9 gray">${board1.lastThread.dateCreated}
                      </span>
                      </c:if>
                      <c:if test ="${board1.lastReply != null}">
                         <a ></a>
                         <br/>
                         <span class="f12">
                         </span>
                         <span class="f9 gray">${board1.lastReply.dateCreated}</span>
                      </c:if>
                      &nbsp;
                   </th>
                   <td class="y_style" style="word-break:keep-all;word-wrap:no-wrap">
                     <struts:iterator var="person" value="board.administrators">
                     <a> </a> 
                     </struts:iterator>
                     &nbsp;
                   </td>
                </tr>
              </struts:iterator>
              <tr>
                 <td class="f_one" colspan="6" style="height:8px">
                 
                 </td>
              </tr>
             </tbody>
          </table>
          </div>
  </struts:iterator> 
  <div>
  <a href="<struts:url action = "initaddCategory"/>" >添加类别</a>
  </div>
</div>
<jsp:include flush="true" page="footer.jsp"></jsp:include>上面的代码没有语法错误,category的数据可以正常显示
但是内层的category.boards中的数据没有显示出来,不知道为什么?
在action中可以看到,categorylist的category对象的boards中是有数据的。

解决方案 »

  1.   

    <s:iterator value="#request.list" status="i">
         ${i.index} //当前对象下标
    ${这里直接写集合中对象的属性名}
    </s:iterator>
      

  2.   

    使用C标签吧,导入标签库,用<c:forEach></c:forEach>
      

  3.   

    <s:iterator value="logoutUrlList" status="status" id="logoutUrl">
    <script src="<s:property value="%{logoutUrl}" />"></script>
    </s:iterator>
      

  4.   

    我之前也为这个问题困扰过,现在解决了我是这么写的:<s:iterator value="list"  id="list"  status="sta">
       <tr>
           <td><s:property   value="bid"/></td>
           <td><s:property   value="bname"/></td>
           <td> <s:property    value="number"/></td>
           <td><s:url action="Mess.action" id="url">
                    <s:param name="mid">
                        <s:property value="bid" />
                    </s:param>
                </s:url>
      <s:a href="%{url}">查看详情</s:a>        
           </td>
           <td>                            
           <s:url action="Jie.action" id="url">
                    <s:param name="sid">
                        <s:property value="bid" />
                    </s:param>
                </s:url>
      <s:a href="%{url}">我要借书</s:a>    
      

  5.   

    <s:iterator>还有个var属性的,用用看
      

  6.   

    不好意思啊,昨天没注意是多层迭代...<struts:iterator var="board1" value="category.boards">改为:<struts:iterator var="board1" value="top.boards">试一下吧应该是可以的
      

  7.   

    谢谢。可以了。
    直接用boards也是可以的。