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){
ModelAndView view = new ModelAndView("list");
return view;
}
VO对象:
public class OptionVo { private String name;
private String options;
private List<String> option; public String getName() {
return name;
} public void setName(String name) {
this.name = name;
} public String getOptions() {
return options;
} public void setOptions(String options) {
this.options = options;
} public List<String> getOption() {
return option;
} public void setOption(List<String> option) {
this.option = option;
}
}
可以看出,controller中参数List内封装的不是基本数据类型,而是一个对象,springMVC源码获取前台的参数是:request.getParameter("")来接收参数的,这样的话,封装参数时就出问题了。
解决办法:
将VO对象再进行封装:
public class Form {
private List<OptionVo> o; public List<OptionVo> getO() {
return o;
} public void setO(List<OptionVo> o) {
this.o = o;
}
}
controller:
@RequestMapping("/test")
public ModelAndView test(Form formm){
ModelAndView view = new ModelAndView("list");
return view;
}
前台页面:
<input type="text" name="o[0].name" value="爱好">
<input type="text" name="o[0].options" value="爱好">
<input type="hidden" name="o[0].option" value="1">
<input type="hidden" name="o[0].option" value="2">
<input type="hidden" name="o[0].option" value="3">
<input type="hidden" name="o[0].option" value="4">
<hr>
<input type="text" name="o[1].name" value="哈哈">
<input type="text" name="o[1].options" value="爱好2">
<input type="hidden" name="o[1].option" value="1">
<input type="hidden" name="o[1].option" value="2">
<input type="hidden" name="o[1].option" value="3">
<input type="hidden" name="o[1].option" value="4">
<hr>
Could not instantiate bean class [java.util.List]: Specified class is an interface] with root cause的更多相关文章
- 【FAQ】SpingMVC实现集合參数(Could not instantiate bean class [java.util.List])
需求,要求批量新增或者改动一个List,在Spring MVC中是不支持以下代码的写法 @RequestMapping(value = "/update", method = Re ...
- SpingMVC实现集合参数(Could not instantiate bean class [java.util.List])
需求,要求批量新增或者修改一个List,在springMVC中是不支持下面代码的写法: @RequestMapping(value = "/update", method = Re ...
- 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 ...
- Failed to instantiate [java.util.List]: Specified class is an interface
错误信息提示: Failed to instantiate [java.util.List]: Specified class is an interface; 错误信息意思:参数错误,参数封装出了问 ...
- 【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 ...
- jdk8中java.util.concurrent包分析
并发框架分类 1. Executor相关类 Interfaces. Executor is a simple standardized interface for defining custom th ...
- Java Concurrency - java.util.concurrent API Class Diagram
摘自: www.uml-diagrams.org Here we provide several UML class diagrams for the Java™ 7 java.util.concur ...
- java.util.LinkedHashMap cannot be cast to xxx 和 net.sf.ezmorph.bean.MorphDynaBean cannot be cast to xxx
java.util.LinkedHashMap cannot be cast to com.entity.Person 使用mybatis, resultMap映射的是实体类Person, 查询出来的 ...
- 2019-8-26 LinkedHashMap 转 List [java.util.LinkedHashMap cannot be cast to com.zq.dataservice.bean.Index]
java.util.LinkedHashMap cannot be cast to com.zq.dataservice.bean.Index 上述错误是在做一个趋势投资demo时遇到的. 说的是链式 ...
随机推荐
- 【原】关于使用sklearn进行数据预处理 —— 归一化/标准化/正则化
一.标准化(Z-Score),或者去除均值和方差缩放 公式为:(X-mean)/std 计算时对每个属性/每列分别进行. 将数据按期属性(按列进行)减去其均值,并处以其方差.得到的结果是,对于每个属 ...
- javascript 中断函数的使用 setInterval();
<script type="text/javascript"> var i=1; var IR1 = setInterval("myMethod()" ...
- bzoj2683
2683: 简单题 Time Limit: 50 Sec Memory Limit: 128 MBSubmit: 1018 Solved: 413[Submit][Status][Discuss] ...
- 关于Deprecated: mysql_result: The mysql extension is deprecated and will be removed in the future: use mysqli or PDO instead in
require_once('connect.php'); $sql = "select * from introduce"; \(query = mysql_query(\)sql ...
- Python学习笔记 之 递归、二维数组顺时针旋转90°、正则表达式
递归.二维数组顺时针旋转90°.正则表达式 1. 递归算法是一种直接或间接调用自身算法的过程. 特点: 递归就是在过程或函数里调用自身 明确的递归结束条件,即递归出口 简洁,但是不提倡 递归次数多 ...
- Map工具系列-05-添加业务参数工具
所有cs端工具集成了一个工具面板 -打开(IE) Map工具系列-01-Map代码生成工具说明 Map工具系列-02-数据迁移工具使用说明 Map工具系列-03-代码生成BySQl工具使用说明 Map ...
- Nginx反向代理tomcat,seesion会话保持。
proxy_pass http://10.0.0.10:8081/monitor/; proxy_cookie_path /monitor/ /; proxy_set_header Host &quo ...
- Solr学习总结(二)Solr的安装与配置
接着前一篇,这里总结下Solr的安装与配置 1.准备 1.安装Java8 和 Tomcat9 ,java和tomcat 的安装这里不再重复.需要注意的是这两个的版本兼容问题.貌似java8 不支持,t ...
- [UML]UML系列——用例图中的各种关系(include、extend)
用例图中的各种关系 一.参与者与用例间的关联关系 参与者与用例之间的通信,也成为关联或通信关系. 二.用例与用例之间的关系 包含关系(include) 扩展关系(extend) 包含关系 (1) 概 ...
- [UML]UML系列——类图class的实现关系Realization
系列文章 [UML]UML系列——用例图Use Case [UML]UML系列——用例图中的各种关系(include.extend) [UML]UML系列——类图Class ...