problem description
- the server receives the json from the client in controller
- controller generates different request objects based on the type field in json, and calls the corresponding service to process it.
- before service processes request, the parameters should be determined first, and then the subsequent processing should be carried out.
normally, the request field should be verified directly in the controller, but my controller can only generate a specific request object based on the type field received in the json, so it can only be verified in the service. But the @ Validated object in the service method doesn"t seem to work. The field in
request has @ NotBlank (message= "xxx") annotations, but it doesn"t work.
what is the problem? Or the @ Validated annotation can only be used in controller?