zoukankan      html  css  js  c++  java
  • s:if 判断

    判断 ArrayList size 是否为0 
    <s:if test="list.size==0"> 
    <s:if> 
    <s:else> 
    </s:else> 
    判断 ArrayList size 是否为null 
    <s:if test="list==null"> 
    <s:if> 
    <s:else> 
    </s:else> 
    OR 
    <s:if test="null==user||user.isEmpty()"> 
    集合为空 
    </s:if><s:else> 
    集合不为空 
    </s:else> 

    or 
    <s:if test="null!=user&&!user.isEmpty()"> 
    集合不为看空 
    </s:if> 
    又OR 
    首先说说<s:if>判断字符串的问题: 
    1、<s:if test="#session.user.username=='c'"> 
    这样是从session中取出username的值,并且判断其是否为c,但是这样判断是不正确的,这样判断的话,根本判断不出来,要改成下面这样: 
    <s:if test="#session.user.username=='c'.toString()"> 
    这样判断才能正确判断,至于原因我也不知道,在网上看到struts2中可能它判断的是char类型。 
    2、<s:if test="#session.user.username=='zhangsan'"> 
    这样写的就是判断username是不是zhangsan,是String的判断,这个是不用加toString()的。 
    3、<s:if test="#session.user.username==0"> 
    这样写的就是判断username是不是0,是int的判断。 
    下面说说判空的问题: 
    1、<s:if test="#session.user.username==null"> 
    struts2中的判空似乎只能这么写,判断非空可以这样写: 
    <s:if test="#session.user.username!=null" > 
    2、在网上还看到这样的判空操作: 
    <s:if test="not empty(memberEducation.doctorSchoolName)"> 
    我用了用,不过没有成功的进行判断。

  • 相关阅读:
    python命令行参数处理
    linux进程管理
    hadoop
    linux进程间通信之信号
    HA for openstack
    ubutun 安装php7.1x
    php 函数小技巧(一)
    git error: RPC failed; result=56, HTTP code = 200
    php面试题汇总四(基础篇附答案)
    php面试题汇总三(基础篇附答案)
  • 原文地址:https://www.cnblogs.com/geniussoft/p/5012560.html
Copyright © 2011-2022 走看看