Java 在Spring MVC中的RequestBody上应用@Valid,其中对象的类型为字符串
我想要一个这样的控制器:Java 在Spring MVC中的RequestBody上应用@Valid,其中对象的类型为字符串,java,spring-mvc,spring-validator,Java,Spring Mvc,Spring Validator,我想要一个这样的控制器: @RequestMapping(method = RequestMethod.POST, path = RETRIEVE) public List<String> getAll(@RequestBody @Valid @Size(min = 1) List<String> numbers) { return service.getAll(numbers); } @RequestMapping(method=RequestMethod.P
@RequestMapping(method = RequestMethod.POST, path = RETRIEVE)
public List<String> getAll(@RequestBody @Valid @Size(min = 1) List<String> numbers) {
return service.getAll(numbers);
}
@RequestMapping(method=RequestMethod.POST,path=RETRIEVE)
公共列表getAll(@RequestBody@Valid@Size(min=1)列表编号){
返回服务.getAll(数字);
}
我不能创建一个新对象并添加变量列表号,因为那样会破坏契约。使用@Valid可以在spring引导中实现吗?参考该线程中的任何答案都不能解决我的问题。