• 整理汇总系统中空值的使用方法,后台+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)



  • 相关阅读:
    NotMapped属性特性
    html.EditorForModel自定义模版
    ASP.NET MVC Core的TagHelper (高级特性)
    C#静态构造函数调用机制
    ASP.NET Forms 身份认证
    特别需要注意!
    观后感
    python进阶日记(生成器)
    python进阶日记(try except)
    python进阶日记(lambda函数)
  • 原文地址:https://www.cnblogs.com/banxian-yi/p/11582602.html
Copyright © 2020-2023  润新知