1、iterator+字符串截取
<s:iterator value="#request.houseList" >
房源333
<li>${id}</li>
<li><s:property value="%{img.trim().substring(0, 29)}" /></li>
<li><a href="agent___getAgHouseDet.action?houseDetId=${id}"><img src="upload/<s:property value="%{img.trim().substring(0, 29)}" />"></li>
</s:iterator>
2、 iterator+ if标签结合
设置了var之后,试试用#获取
<s:iterator value="listUsers" var="u">
< dl>
<s:if test="#u.singerpic=='' || #u.singerpic==null">
<dd class="dd">
<a href="vote.action?userid=${u.id }">
<img src="images/ta.jpg" οnclick="alert('投票成功!')"/> </a>
</dd>
</s:if>
</dl>
< /s:iterator>注意:var="new" 就不行 不知道是否new是关键字 奇怪~
3、iterator+字符串截取+if标签结合
<s:iterator value="#request.houseListNew" id='houseListNew'
var="a">
<li><s:if test="#a.imgType==0">
<a href="house___getHouseDet.action?houseDetId=${id}"><img
src="upload/<s:property value="%{img.trim().substring(0, 29)}" />"></a>
<a href="#"><p>${name}</p></a>
<span>${ffDetail}</span><span>${g}</span>
</s:if> <s:else>
<a href="house___getHouseDet.action?houseDetId=${id}"> <img
src="upload/<s:property value="%{img.trim().substring(30, 59)}" />"></a>
<a href="#"><p>${name}</p></a>
<span>${ffDetail}</span><span>${g}</span>
</s:else></li>
</s:iterator>
4、直接截取
agent为action的属性 set get private Agent agent
<img src="upload/<s:property value="%{agent.headImg.trim().substring(0, 29)}" />">
request.setAttribute方式貌似搞不通
5、单独if
<s:set name="houseType" value="#request.houseType"/>
<s:if test="#houseType==1">
<h4>精品楼盘</h4></s:if>
6、 <c:choose>
<c:when test="${!empty untClassTwoList}">
<c:forEach items="${untClassTwoList}" var="info" varStatus="ss">
<a href="menus.action?untClass.id=${info.id}&index=${ss.index+1}"
class="leftbtn" >
<c:choose>
<c:when test="${ss.index+1==index}">
<div class="ok"><font color="#FF0000" size="+2">${info.name}</font></div>
</c:when>
<c:otherwise>${info.name}</c:otherwise>
</c:choose>
</a>
</c:forEach>
</c:when>
<c:otherwise>
<c:forEach items="${productList }" var="pro">
<a href="products.action?product.id=${pros.id}" class="leftbtn">${pro.name }</a>
</c:forEach>
</c:otherwise>
</c:choose>
其中红色index 为后台传来得${index}