org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.List]: Specified class

错误:org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.List]: Specified class

这是我使用Spring MVC的时候出的错误,在前台将多个信息的id封装成一个集合后传递到控制层,向让这些id自动映射到控制层方法的参数上

我这个参数是一个List类型,因为Spring MVC是不能这样直接映射到集合类型的参数的,我们需要将这个集合类型的参数封装到一个类中,下面举个例子:

前台封装好的id集合名称:ids,

映射到控制层的方法:

1 @requestMapping("/test")
2 public void test(TestVo testVo) throws ExcepTion{
3
4 // 你的代码
5 }

TestVo类(我们的封装类)

1 public class TestVo {
2
3 private List ids;    // 接收前台传递的多个id,属性名称一定要和前台传递的id集合的名称相同
4
5 // ids的setter和getter方法,这个必须要有,我在这里就不写了
6
7 }

学习不能停,各位加油!

原文地址:https://www.cnblogs.com/caizhen/p/9215623.html

时间: 2024-10-17 03:02:38

org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [java.util.List]: Specified class的相关文章

【FAQ】SpingMVC实现集合參数(Could not instantiate bean class [java.util.List])

需求,要求批量新增或者改动一个List,在Spring MVC中是不支持以下代码的写法 @RequestMapping(value = "/update", method = RequestMethod.POST) public String update(List<ProductCollocation> productCollocations ,HttpServletRequest request, RedirectAttributes redirectAttribute

【spring mvc】后台spring mvc接收List参数报错如下:org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface

后台spring mvc接收List参数报错如下:org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Specified class is an interface org.springframework.beans.BeanInstantiationException: Failed to instantiate [java.util.List]: Speci

org.springframework.beans.BeanInstantiationException: Failed to instantiate [demo.Words]: No default constructor found; nested exception is java.lang.NoSuchMethodException: demo.Words.&lt;init&gt;()

org.springframework.beans.BeanInstantiationException: Failed to instantiate [demo.Words]: No default constructor found; nested exception is java.lang.NoSuchMethodException: demo.Words.<init>()或者是: org.springframework.beans.BeanInstantiationException

Could not instantiate bean class [java.util.List]: Specified class is an interface] with root cause

最近项目中页面比较复杂,springMVC传参过程中遇到这样一个错误:Could not instantiate bean class [java.util.List]: Specified class is an interface] with root cause 经研究发现这是参数封装出了问题. 还原代码: @RequestMapping("/test") public ModelAndView test(List<OptionVo> ov){ ModelAndVie

org.springframework.web.util.NestedServletException: Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.jboss.resteasy.plug

之前做的项目是resteasy的上传,代码没有问题,断点都不进来呢. 我以为可以直接移植到SpringMVC,但是SpringMVC不支持MultipartFormDataInput , 用MultipartFile就可以了.老的无法兼容新的.正确代码如下 @RequestMapping(value = "/importExcelForEduQuestion",produces = "application/json; charset=utf-8")@Respons

Spring MVC集成thymeleaf时提示:defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException

错误提示: defined in ServletContext resource [/WEB-INF/SrpingMVCTest-servlet.xml]: Instantiation of bean failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.thymeleaf.templateresolver.ServletContex

【报错】org.springframework.beans.factory.BeanCreationException: Error creating bean with name &#39;webSocketHandlerMapping&#39; defined in class path resource

环境:maven+eclipse+jdk1.8 [tomcat使用的是maven自带的插件,实质原因就是出在tomcat版本问题] 背景:在进行SSM集成WebSocket的时候,项目启动报org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'webSocketHandlerMapping' defined in class path resource错误,详细如下 org.

org.springframework.beans.factory.BeanCreationException: Error creating bean with name

这个问题在别人电脑上面没有出现,但我的电脑就出现了,在网上找各种解决方法:有的说是asm.jar冲突,有的说要配置byName,有的说是路径问题但路径明显是正确的. 严重: Exception sending context initialized event to listener instance of class org.springframework.web.context.ContextLoaderListener org.springframework.beans.factory.B

spring Boot异步操作报错误: org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type &#39;com.self.spring.springboot.Jeep&#39; available

我也是最近开始学习Spring Boot,在执行异步操作的时候总是汇报如下的错误: Exception in thread "main" org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type 'com.self.spring.springboot.Jeep' available at org.springframework.beans.factory.sup