当前位置: 代码迷 >> Web前端 >> <s:if>简略使用
  详细解决方案

<s:if>简略使用

热度:122   发布时间:2012-11-05 09:35:12.0
<s:if>简单使用
一、<s:if test="          "> </s:if>       test内容是判断内容

        1、list 的非空判断,需要判断“是否为空”和“size()”两项,普通属性或对象只需判断前者

                    eg:        <s:if test="list!= null && list.size() > 0">

       2、emnu对象的判断,可判断其“name”属性,如下“order”的payment属性是emnu,

                    eg:        <s:if test="order.payment.name == 'payment.pao'"> 判断当前order的payment属性的name是否为“payment.pao”

    二、<s:iterator value="         "  id="f"       status=" stuts" >          value需要进行iterator的list,f当前对象

                    eg:       <s:iterator value="list" id="f" status="stuts">
                                     <s:if test="#stuts.index % 7 == 0">

                                     //如果当前对象的index属性(表示当前对象是第*个对象)模7余数为0就、、、

                                     <s:text name="%{price}"/>          //取出当前对象的price属性

                                     </s:if>

                                    <s:if test="#f==3">

                                     //如果当前对象的值为3就、、、

                                    </s:if>>

                               </s:iterator>

     三、当显示一个emnu属性的值时,可以将该属性的name属性作为元素进行国际化的方式拿出

                              <s:text name="%{order.payment.name}"/>



本文来自CSDN博客,转载请标明出处:http://blog.csdn.net/wcx11/archive/2008/11/07/3247122.aspx
  相关解决方案