小工具知识网

当前位置: 首页 > 行业知识 > 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

2026-12-06 22:00:17 来源:互联网转载

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

出现了500错误

先看代码

mapper层代码

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

控制层

前端

 页面展示

然后页面显示500错误

 查看控制台

  报错:No primary index.php/tags-1038.html" >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

 

 

上一篇:专业洁面指南,如何深度清洗弥勒尚瘦脸面膜的秘密

下一篇:QQ群聊创建全攻略,轻松掌握创建新群聊的秘诀!