struts2标签Iterator迭代时获取下标、判断list是否为空

来源:互联网 发布:湘潭湖南软件职业学院 编辑:程序博客网 时间:2024/05/29 10:51

一: Iterator迭代时获取下标

例如:<s:iterator id="obj" value="list" status="index">

<!---输出当前元素的属性-->

<s:property value="property"/>

 

<!---输出当前迭代元素的索引-->

<s:property value="#index.index"/>

 

<!---输出当前迭代了几个元素-->

<s:property value="#index.count"/>

 

<!---返回当前迭代元素的索引是否为奇数-->

<s:property value="#index.odd"/>

 

<!---返回当前迭代元素的索引是否为偶数-->

<s:property value="#index.event"/>

 

<!---返回当前元素是否为第一个-->

<s:property value="#index.first"/>

 

<!---返回当前元素是否为最后一个-->

<s:property value="#index.last"/>

 

<!---返回当前元素下标-->

<s:property value="#index.getCount()" />


二:判断list是否为空。

方式1:

<s:if test="#ziyuan.user.ziyuans.size()>2">

长度大于2...的操作

</s:if>

<s:else>

...小于2的操作

</s:else>

方式2:

<s:if test="#ziyuan.bagInfos.isEmpty()">

...为空
</s:if>
<s:else>

...不为空

</s:else>

三、获取url中的参数

<!--<s:property value="#parameters.categoryType[0]"/>-->
     <s:if test='#parameters.categoryType[0]=="2"'>
          <a href="javascript:void(0)" class="easyui-linkbutton" id="selectStudyArticleCategory">选择文章类目</a>${category.cname }
     </s:if>
     <s:if test='#parameters.categoryType[0]=="3"'>
          <a href="javascript:void(0)" class="easyui-linkbutton" id="selectJobArticleCategory">选择文章类目</a>${category.cname }
     </s:if>

0 0