@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调用。

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-08
  • 2021-11-06
  • 2022-01-11
  • 2021-07-30
  • 2022-12-23
  • 2022-01-19
猜你喜欢
  • 2022-01-19
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-15
  • 2022-12-23
相关资源
相似解决方案