一、后台:
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)