@Test
    public void test01(){
        String s1 = null;  // null对象
        String s2 = "";  // 空串
        String s3 = " "; // 带空格
        System.out.println("s1:"+ StringUtils.hasText(s1));
        System.out.println("s2:"+ StringUtils.hasText(s2));
        System.out.println("s3:"+ StringUtils.hasText(s3));
    }
    /*
    控制台输出:
		s1:false
		s2:false
		s3:false
*/

用 StringUtils.hasText() 代替
Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐