Validation of a list of objects in Spring

后端 未结 12 1241
無奈伤痛
無奈伤痛 2020-11-28 05:30

I have the following controller method:

@RequestMapping(value=\"/map/update\", method=RequestMethod.POST, produces = \"application/json; charset=utf-8\")
@Re         


        
12条回答
  •  执笔经年
    2020-11-28 05:55

    Validating a collection does not work directly.

    For example: what should it do if multiple elements fail the validation? Stop after first validation? Validate all (if so what is to be done with the collection of messages)?

    If in your configuration Spring delegates to a Bean Validator provider like Hibernate Validator, you should look up for ways of implementing a collection validator there.

    For Hibernate, a similar problem is discussed here

提交回复
热议问题