Servlet.service() for servlet [springmvc] in context with path [] threw exception [Request processing failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate **[[Ljava.lang.Object;]: No default constructor found; **nested exception is java.lang.NoSuchMethodException: [Ljava.lang.Object;.()] with root causejava.lang.NoSuchMethodException: [Ljava.lang.Object;.()我在做一个网站开发,我希望在Cotroller层中传入Object类型的可变参数,就一直报这个错误,请问该怎么解决呢?以下是我的代码://可变参数做查询
//localhost/detailsss/?detail=徐国权&detail=12
@RequestMapping("/detailsss/")
public String queryDetails(Model model,Object...detail){
try {
Object consume = null;
List<Object> list = new ArrayList<>();
for(Object obj : detail){
if(obj instanceof String){
consume = new String(((String) obj).getBytes("iso-8859-1"),"utf-8");
}
else if(obj instanceof Integer){
consume = (int)obj;
}
else if(obj instanceof Date){
consume = (Date)obj;
}
else if(obj instanceof Time){
consume = (Time)obj;
}else{
consume = obj;
}
list.add(consume);
}
//调用service的方法
List<Detailed> details = comsumeService.queryDetails(list);
model.addAttribute("details",details);
return "comsume_info";
} catch (Exception e) {
e.printStackTrace();
return "err";
}
}
添加回答
举报
0/150
提交
取消