三亩地 三亩地SAN MU DI · CODE DIARY
ARTICLE DETAIL

日记详情

真实记录编程学习的某一天,欢迎挑你感兴趣的翻一翻。

记录-boot项目校验字符串

记录-boot项目校验字符串

1、用 Apache Commons Lang 3 依赖中的StringUtils.isBlank(CharSequence cs)

StringUtils.isBlank(CharSequence cs) 用来判断字符串是否为空、为 null 或者只包含空格

引入依赖

<!-- Apache Commons Lang3工具--> <dependency> <groupId>org.apache.commons</groupId> <artifactId>commons-lang3</artifactId> <version>3.12.0</version> </dependency>

2、用 Spring 自带的工具类 StringUtils.hasText(String str)

StringUtils.hasText(String str):是否包含真正的文本内容。如果字符串是null""或者全都是空格,返回false

3、汇总

← 返回列表