有時候,controller參數(shù)接收json對象,我們需要判斷該對象中的屬性值是否都不為空(都是必須的)/至少有一個屬性值不為空,其中字符串屬性不為null和不為“”,如果對象參數(shù)多,controller里面遍歷每一個屬性去判斷,代碼冗余。 當(dāng)然還有另外的方法,比如spring框架中的注解@NotNull,@NotBlank,@Valid。 1 2 3 4 5 6 7...
www.dbjr.com.cn/program/328851m...htm 2025-6-9