SpringMVC Failed to instantiate [java.util.List]: Specified class is an interface

@RequestMapping("/test/save")
public Result save(Integer threadNum, Integer pageIndex, Integer pageSize, Integer totalPage,  List<String> productCodes) {
...
}

SpringMVC中使用List<T>参数,用Postman测试接口报错,提示:

org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface
SpringMvc报错解决:Failed to instantiate [java.util.List]: Specified class is an interface 

解决方式:
方法1:List参数加上@RequestParam(value = "productCodes")注解,调用方式不变

@RequestMapping("/saveAllGroupProductPrice")
public Result save(Integer threadNum, Integer pageIndex, Integer pageSize, Integer totalPage, @RequestParam(value = "productCodes", required = false) List<String> productCodes) {
...
}

方法2:请求参数封装为XxxReqvo,使用@RequestBody注解,改用application/json调用。

原文地址:https://www.cnblogs.com/cdfive2018/p/13894985.html