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)



  • 相关阅读:
    some tips
    ORA00847: MEMORY_TARGET/MEMORY_MAX_TARGET and LOCK_SGA cannot be set together
    Chapter 01Overview of Oracle 9i Database Perfomrmance Tuning
    Chapter 02Diagnostic and Tuning Tools
    变量与常用符号
    Chapter 18Tuning the Operating System
    标准输入输出
    Trace files
    DBADeveloped Tools
    Chapter 03Database Configuration and IO Issues
  • 原文地址:https://www.cnblogs.com/banxian-yi/p/11582602.html
Copyright © 2011-2022 走看看