针对表单数据验证,判断字符串是否为空

方法一:最常见:字符串为null或者“”

public static boolean isEpy(String str) {
    if (null == str) return true;
    if (str.trim() == "") return true;
    return false;
}

方法二:字符串为null或者“”

public static boolean isEpy(String str) {
    if (null == str) return true;
    if (str.trim().equals("")) return true;
    return false;
}

方法三:字符串为null或者长度小于等于0

public static boolean isEpy(String str) {
    if (null == str) return true;
    if (str.trim().length() <= 0) return true;
    return false;
}

方法四:字符串为null或者为空

public static boolean isEpy(String str) {
    if (null == str) return true;
    if (str.trim().isEmpty()) return true;
    return false;
}