iterator+字符串截取 || iterator+ if标签结合 ||iterator+字符串截取+if标签结合 || <c:choose>+<c:when>+<c:forEach>

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}

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值