springboot传递List类型参数报错 No primary or single unique constructor found for interface java.util.List

springboot传递List类型参数报错 No primary or single unique constructor found for interface java.util.List

昨天在做毕设进行一对多插入的时候

出现了500错误

先看代码

mapper层代码

这里我是list集合进行一对多插入

控制层

前端

 页面展示

然后页面显示500错误

 查看控制台

  报错:No primary or single unique constructor found for interface java.util.List
    at org.springframework.beans.BeanUtils.getResolvableConstructor

request失败

    因为获取controller参数是在进入controller方法之前(因为需要转换成controller需要的参数),所以肯定是在获取controller参数之前。
那是处理器映射过程中的问题。
处理器映射需要将请求路径与@RequestMapping 匹配。看来这个过程还需要映射参数。

Spring MVC获取参数不带注解的唯一要求就是参数名和Http请求参数名一致。一般的 List 参数只是用逗号分隔。不会有所谓的名字,所以才有可能。这是结果。
 

 最后插入数据成功

 

参考文章:Spring MVC passed List type parameter error: No primary or default constructor found for interface java.util.List] Use two annotations to solve - Krybot

 

 

转载请说明出处内容投诉
CSS教程_站长资源网 » springboot传递List类型参数报错 No primary or single unique constructor found for interface java.util.List

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买