zoukankan      html  css  js  c++  java
  • 整理汇总系统中空值的使用方法,后台+jsp

    一、后台:

    1. entity.getStringValue().isEmpty();//字符串自带方法,未发现非空方法
    实现原理:判断值的长度

    public boolean isEmpty() {
       return value.length == 0;
    }

    2.StringUtils.isEmpty(orderby)

    实现原理:为null 或者 长度==0

    public static boolean isEmpty(final CharSequence cs) {
       return cs == null || cs.length() == 0;
    }

     StringUtils.isNotEmpty(message)

    实现原理:不为null ,且长度>0

        public static boolean isNotEmpty(final CharSequence cs) {
            return !StringUtils.isEmpty(cs);
        }

     3.entity.getParent().setParentIds(StringUtils.EMPTY);

    StringUtils.EMPTY的定义;

    public static final String EMPTY = "";

    4.StringUtils.isBlank(sessionId)

    实现原理:isBlank 是在 isEmpty 的基础上进行了为空(字符串都为空格、制表符、tab 的情况)的判断。

    public static boolean isBlank(final CharSequence cs) {
            int strLen;
            if (cs == null || (strLen = cs.length()) == 0) {
                return true;
            }
            for (int i = 0; i < strLen; i++) {
                if (Character.isWhitespace(cs.charAt(i)) == false) {
                    return false;
                }
            }
            return true;
        }
    StringUtils.isNotBlank(vaccineName)
    实现原理:是在 isBlank基础上的
       public static boolean isNotBlank(final CharSequence cs) {
            return !StringUtils.isBlank(cs);
        }

     比如:
    StringUtils.isEmpty(" ") = false

    StringUtils.isBlank(" ") = true

    5.bsManageProduct.getVaccineid() !=null && !"".equals(bsManageProduct.getVaccineid())

    二、前端

    1.jQuery中 empty

    <c:if test="${not empty user.id}">
    <c:if test="${empty de.pinnum }">

     2.if(articleSelect != null && articleSelect.length > 0)



  • 相关阅读:
    Windows 代码实现关机(直接黑屏)
    Windows SEH学习 x86
    Smali 语法文档
    SIOCADDRT: No such process
    Windbg 常用命令整理
    ida GDB 远程调试
    IDA 使用技巧
    Windows X64 Patch Guard
    C 和C++ 名称修饰规则
    【转载】 硬盘主引导记录(MBR)及其结构详解
  • 原文地址:https://www.cnblogs.com/banxian-yi/p/11582602.html
Copyright © 2011-2022 走看看