如何指定在Bean验证列表对象不是空约束

问题描述 投票:0回答:1
class Person{

    //insert some validation annotation here to make sure that list CANNOT contain null entry
    private List<String> addressList;

   //rest of the code
}

我需要验证,以确保AddressList中不能包含任何空值。

java validation annotations javabeans
1个回答
0
投票

您可以使用javax.validation.constraints.NotNull标注为AddressList中把限制这个不能为空。请参阅https://docs.oracle.com/javaee/6/api/javax/validation/constraints/NotNull.html

© www.soinside.com 2019 - 2024. All rights reserved.