@NotNull、@NotBlank和@NotEmpty

 

@NotNull:The annotated element must not be {@code null}.Accepts any type.
	只是校驗不能爲null,任何類型的數據都可以用
@NotEmpty:Asserts that the annotated string, collection, map or array is not {@code null} or empty.
	校驗String、集合等不爲null不是空的(“ ”空格被認爲非空)
@NotBlank:Validate that the annotated string is not {@code null} or empty.The difference to {@code NotEmpty} is that trailing whitespaces are getting ignored.
	校驗String不能爲null也不能爲“ ”。也就是說,如果是“ ”,@NotEmpty爲true,@NotBlank爲false。

三者關係:@NotNull爲其他兩個的元註解。如下圖

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章