Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在Spring MVC中的RequestBody上应用@Valid,其中对象的类型为字符串_Java_Spring Mvc_Spring Validator - Fatal编程技术网

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引导中实现吗?

参考该线程中的任何答案都不能解决我的问题。