How Java validation verifies List

Annotations from the validation framework are used in the

entity class, such as @ NotNull.
@ Validation User user the entity class in Controller to determine whether it meets the requirements.

but if it is a list object, such as @ Validation List < User > userList, the validation framework will fail. What can I do to be ineffective?

Mar.14,2021

try another annotation, @ Size (min=, max=) to verify that the length of the object (Array,Collection,Map,String) is within a given interval.


use this annotation @ Valid, to implement the verification function


and wrap it again with @ Valid

Menu