日期:2014-05-18  浏览次数:20730 次

在线等:求用Struts标签循环显示四行四列的图片

=======================================================================
存储数据集的list:

  public ActionForward getAllSideTypeAction(
  ActionMapping mapping,
  ActionForm form,
  HttpServletRequest request,
  HttpServletResponse response) throws Exception {  
   
   
  AlbumModel albummodel =new AlbumModel();
AlbumDAO albumdao=new AlbumDAO();

java.util.ArrayList list=new java.util.ArrayList();
list=albumdao.getAllalbum1(albummodel);
request.setAttribute("list", list);

if(list==null)
System.out.println(list.size());

request.setAttribute("list", list);
return mapping.findForward("addtype"); //对应到下面的jsp页面上了。
  }


========================================================================
下面是图片循环成四行四列的代码:


<table width="100%" border="0" cellspacing="0" cellpadding="0" class="photo_small">
<logic:iterate name="list" id="a" indexId="i" offset="1">
<bean:define id="temp" value="${(i-1)%4}"></bean:define>
<bean:define id="temp1" value="${i%4}"></bean:define>
<logic:equal name="temp" value="0">
<tr>
</logic:equal>


<td width="25%">

<a href="showTypePhoto.do?ialbumId=<bean:write name="a" property="palbum_id"/>">
<!-- 如果没有相片就显示一张默认的图片--> 
<logic:empty name="a" property="cname">
<img src="images/photo01.gif" alt="photos" border="0" />
</logic:empty> 
<!--显示此分类最新上传的相片-->
 <logic:notEmpty name="a" property="cname">

<img src="<bean:write name="a" property="cname"/>"alt="photos" border="0" />
</logic:notEmpty>
</a>


<div><strong> 
<bean:write name="a" property="cname" />
<!-- 显示相册名字-->
</strong> <br>
<a href="#"> <logic:equal name="a" property="cname"value="2">
保密
</logic:equal> 
</a> 


<a href="editPhoto.do?palbum_id=<bean:write name="a" property="palbum_id"/>">
修改 
</a>


 <html:link page="/deleteHouseAlbum.do" paramId="palbum_id" paramName="a" paramProperty="palbum_id"
onclick="return confirm(' 您确定删除整个像册吗?\n注意:此操作将导致像册下所有相片全部删除!');">
删除
</html:link>
</div>


</td>


<logic:notEqual name="i" value="0">
<logic:equal name="temp1" value="0">
</tr>
</logic:equal>
</logic:notEqual>
</logic:iterate>
<logic:notEqual name="temp1" value="0">
</tr>
</logic:notEqual>
<tr>
<td colspan="4">
<div><logic:notEmpty name="list" scope="request">

<logic:iterate name="list" id="a" scope="request" length="1">

<logic:notEqual name="a" value="1">
<logic:equal name="curPage" value="1"