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

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

出现了500错误

先看代码

mapper层代码

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

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

控制层

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 页面展示

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

然后页面显示500错误

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  报错: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 参数只是用逗号分隔。不会有所谓的名字,所以才有可能。这是结果。

 

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

 最后插入数据成功

springboot传递List类型参数报错 No primary or single unique constructor found for interface java.util.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

 

 

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/2aeb59698e.html