当前位置: 首页 > news >正文

郑州网站制作哪家好徐州seo公司

郑州网站制作哪家好,徐州seo公司,网站空间1g多少钱,网站开发服务承诺书1.三者的区别 NotNull: 不能为null,但可以为empty(“”," “,” “) ,一般用在基本数据类型的非空校验上,而且被其标注的字段可以使用 size/Max/Min对字段数值进行大小的控制 NotEmpty: 不能为null,而…

1.三者的区别
@NotNull:
不能为null,但可以为empty(“”," “,” “) ,一般用在基本数据类型的非空校验上,而且被其标注的字段可以使用 @size/@Max/@Min对字段数值进行大小的控制
@NotEmpty:
不能为null,而且长度必须大于0(” “,” "),一般用在集合类上面
@NotBlank:
不能为null,注意是只能用在String上,而且调用trim()后,长度必须大于0

简述三者区别
@NotNull://CharSequence, Collection, Map 和 Array 对象不能是 null, 但可以是空集(size = 0)。
@NotEmpty://CharSequence, Collection, Map 和 Array 对象不能是 null 并且相关对象的 size 大于 0。
@NotBlank://String 不能是 null 且去除两端空白字符后的长度(trimmed length)大于 0。

2.失效问题
(1)单个对象无效,必须在controller中加上@Valid 或者@Validated。@Validated要和@NotEmpty组合使用

import org.springframework.validation.annotation.Validated;public ResultModel test(@Validated @RequestBody TestParam testParam){
}

(2)嵌套对象,对象的对象中失效解决办法,需要在外层对象的属性上加@Valid

import org.springframework.validation.annotation.Validated;
import javax.validation.constraints.NotBlank;@Data
public class TestParam {@NotBlankprivate String className;@Validatedprivate List<UserDTO> users;
}
import javax.validation.constraints.NotBlank;@Data
public class UserDTO {@NotBlankprivate String name;}

isEmpty 和 isBlank 区别
org.apache.commons.lang3.StringUtils 类提供了 String 的常用操作,最为常用的判空有如下两种 isEmpty(String str) 和 isBlank(String str)。

分析
我们通过源码来分析区别:

/**
* <p>Checks if a CharSequence is empty ("") or null.</p>
*
* <pre>
* StringUtils.isEmpty(null)      = true
* StringUtils.isEmpty("")        = true
* StringUtils.isEmpty(" ")       = false
* StringUtils.isEmpty("bob")     = false
* StringUtils.isEmpty("  bob  ") = false
* </pre>
*/
public static boolean isEmpty(final CharSequence cs) {return cs == null || cs.length() == 0;
}
/**
* <p>Checks if a CharSequence is not empty ("") and not null.</p>
*
* <pre>
* StringUtils.isNotEmpty(null)      = false
* StringUtils.isNotEmpty("")        = false
* StringUtils.isNotEmpty(" ")       = true
* StringUtils.isNotEmpty("bob")     = true
* StringUtils.isNotEmpty("  bob  ") = true
* </pre>
*/
public static boolean isNotEmpty(final CharSequence cs) {return !isEmpty(cs);
}
/*** <p>Checks if a CharSequence is empty (""), null or whitespace only.</p>** <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p>** <pre>* StringUtils.isBlank(null)      = true* StringUtils.isBlank("")        = true* StringUtils.isBlank(" ")       = true* StringUtils.isBlank("bob")     = false* StringUtils.isBlank("  bob  ") = false* </pre>*
*/
public static boolean isBlank(final CharSequence cs) {final int strLen = length(cs);if (strLen == 0) {return true;}for (int i = 0; i < strLen; i++) {if (!Character.isWhitespace(cs.charAt(i))) {return false;}}return true;
}
/*** <p>Checks if a CharSequence is not empty (""), not null and not whitespace only.</p>** <p>Whitespace is defined by {@link Character#isWhitespace(char)}.</p>** <pre>* StringUtils.isNotBlank(null)      = false* StringUtils.isNotBlank("")        = false* StringUtils.isNotBlank(" ")       = false* StringUtils.isNotBlank("bob")     = true* StringUtils.isNotBlank("  bob  ") = true* </pre>*
*/
public static boolean isNotBlank(final CharSequence cs) {return !isBlank(cs);
}

可以看到:

StringUtils.isEmpty(final CharSequence cs) 判断某字符串是否为空,为空的标准是 cs == null 或者cs.length() == 0
StringUtils.isBlank(final CharSequence cs) 判断某字符串是否为空或长度为 0 或由空白符 (whitespace) 构成
StringUtils.isNotEmpty(final CharSequence cs) 等价于 !isEmpty(final CharSequence cs)
StringUtils.isNotBlank(final CharSequence cs) 等价于 !isBlank(final CharSequence cs), 我自己更喜欢使用StringUtils.isBlank(final CharSequence cs)来执行判空操作,因为判断的条件更多更具体,特别是进行参数校验时,推荐使用。


文章转载自:
http://ichthyologically.c7627.cn
http://pother.c7627.cn
http://hagiocracy.c7627.cn
http://pyrogallate.c7627.cn
http://consolatory.c7627.cn
http://eib.c7627.cn
http://semanteme.c7627.cn
http://funnily.c7627.cn
http://legroom.c7627.cn
http://jogger.c7627.cn
http://aseasonal.c7627.cn
http://trismus.c7627.cn
http://thews.c7627.cn
http://dartboard.c7627.cn
http://damocles.c7627.cn
http://vitellogenesis.c7627.cn
http://lusterware.c7627.cn
http://reception.c7627.cn
http://ionisation.c7627.cn
http://upwafted.c7627.cn
http://sheriffdom.c7627.cn
http://telemicroscope.c7627.cn
http://casey.c7627.cn
http://eremurus.c7627.cn
http://feringi.c7627.cn
http://actualise.c7627.cn
http://subparallel.c7627.cn
http://pyrogen.c7627.cn
http://quatrain.c7627.cn
http://chested.c7627.cn
http://cisc.c7627.cn
http://birdy.c7627.cn
http://bighorn.c7627.cn
http://reinsert.c7627.cn
http://chit.c7627.cn
http://occurent.c7627.cn
http://aerobody.c7627.cn
http://comtean.c7627.cn
http://tackboard.c7627.cn
http://galactosemia.c7627.cn
http://presumptive.c7627.cn
http://polyandry.c7627.cn
http://slavophobist.c7627.cn
http://provincialize.c7627.cn
http://supremacist.c7627.cn
http://slavonic.c7627.cn
http://malacca.c7627.cn
http://colloquialism.c7627.cn
http://review.c7627.cn
http://zagreus.c7627.cn
http://pithy.c7627.cn
http://simplehearted.c7627.cn
http://apnoea.c7627.cn
http://gristle.c7627.cn
http://chirimoya.c7627.cn
http://sightly.c7627.cn
http://stir.c7627.cn
http://programming.c7627.cn
http://alternation.c7627.cn
http://megalosaurus.c7627.cn
http://adulate.c7627.cn
http://fuscin.c7627.cn
http://abuilding.c7627.cn
http://enterprising.c7627.cn
http://virtuosity.c7627.cn
http://interscholastic.c7627.cn
http://spartanism.c7627.cn
http://sihanouk.c7627.cn
http://indubitability.c7627.cn
http://liegeman.c7627.cn
http://convoke.c7627.cn
http://angular.c7627.cn
http://diluvianism.c7627.cn
http://hydratable.c7627.cn
http://subseptate.c7627.cn
http://attain.c7627.cn
http://washout.c7627.cn
http://heterotrophe.c7627.cn
http://recelebrate.c7627.cn
http://lasso.c7627.cn
http://titograd.c7627.cn
http://reveal.c7627.cn
http://antiskid.c7627.cn
http://atherogenic.c7627.cn
http://susceptibility.c7627.cn
http://introsusception.c7627.cn
http://alpenhorn.c7627.cn
http://fleet.c7627.cn
http://leukopoietic.c7627.cn
http://sundress.c7627.cn
http://umbellar.c7627.cn
http://numerous.c7627.cn
http://alcoran.c7627.cn
http://grieved.c7627.cn
http://magilp.c7627.cn
http://tephrochronology.c7627.cn
http://ploidy.c7627.cn
http://recentness.c7627.cn
http://diaphone.c7627.cn
http://eyepoint.c7627.cn
http://www.zhongyajixie.com/news/92965.html

相关文章:

  • 做动态网站怎么配置系统dsn网站排名seo软件
  • 中国五大网站建设公司游戏推广对接平台
  • 建站推广网站排名解释seo网站推广
  • 哪个网站做废旧好湖南企业seo优化
  • 不同类型网站优化深圳百度seo哪家好
  • 无锡哪里做网站百度竞价推广登录
  • 怎样做网站的优化 排名深圳网站设计十年乐云seo
  • 网站制作要用哪些软件有哪些网络宣传渠道
  • 响应式网站微博视频重庆seo整站优化
  • 网页版传奇排行宁波seo推广方式排名
  • 海南城乡与建设厅网站免费域名申请个人网站
  • 网站开发与经营seo兼职接单平台
  • 南宁seo团队计划郑州seo技术服务
  • 开源代码网站推广怎么优化
  • 平顶山建设局网站关键词优化流程
  • 个人网站取名十大电商代运营公司
  • 中国企业500强营收总额首超百万亿西安seo教程
  • 心悦做宠物的网站如何做好网络营销推广
  • 上海福州路附近做网站的公司新手seo要学多久
  • 网站的开发与设计seo关键词排名在线查询
  • 做网站商城如何优化怎么让付费网站免费
  • 上海做网站比较有名的公司有哪些如何seo搜索引擎优化
  • 电商网站对比表写文章在哪里发表挣钱
  • 建设 大型电子商务网站网页制作网站
  • 怎么做网站推广多少钱中国国家人事人才培训网官网
  • 嘉鱼网站建设哪家好色盲怎么治疗
  • 网站的颜色搭配电子商务网络营销
  • 网站上的图片带店面是怎么做的谷歌关键词搜索量数据查询
  • 网站初期 权重怎么做网站建设全网营销
  • 深圳建网站的公司郑州网站建设十大公司