嵌套循环 list中的list
<s:iterator id="list" value="infoList" status="sta"> <s:iterator id="info" value=“infoList[#sta.index]"> <p> <a href="/expert/a/${info.infoId }.shtml" title="${info.subject }"> <s:if test="subject.length()>=21"> <s:property value='subject.substring(0,20)'/><b>. . .</b> </s:if> <s:else> ${info.subject } </s:else> </a> <span><s:date name="publicTime" format="yyyy-MM-dd" /> </p> </s:iterator> </s:iterator>
限制循环次数,取前几条记录
<s:subset source="infoList[#sta.index]" start="0" count= "1" > <!-- start 开始 count 显示几条 --> <s:iterator id="info" <p> <a href="/expert/a/${info.infoId }.shtml" title="${info.subject }"> <s:if test="subject.length()>=21"> <s:property value='subject.substring(0,20)'/><b>. . .</b> </s:if> <s:else> ${info.subject } </s:else> </a><span><s:date name="publicTime" format="yyyy-MM-dd" /> </p> </s:iterator> </s:subset>
集合list 的长度
<s:property value="list.size"/><br/> <s:property value="list.size()"/><br/> <s:property value="#request.list.size"/><br/> <s:property value="#request.list.size()"/><br/>
判断list是否为空
<s:if test="memExpertList == null || memExpertList.size <= 0"> <tr><td align="center" colspan="3" height="23"><font color="red"> 无相关记录!</font></td></tr> </s:if>
struts2截取字符串,超过长度省略号
<s:if test="subject.length()>=21"><s:property value='subject.substring(0,20)'/><b>. . .</b></s:if> <s:else>${info.subject }</s:else>
struts2时间格式化
<s:date name="publicTime" format="yyyy-MM-dd HH:mm:ss" />
原创文章,作者:Maggie-Hunter,如若转载,请注明出处:https://blog.ytso.com/10449.html