为了账号安全,请及时绑定邮箱和手机立即绑定

[Ljava.lang.Object;]: No default constructor found

[Ljava.lang.Object;]: No default constructor found

HUX布斯 2019-04-18 17:15:04
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";         }            }
查看完整描述

4 回答

?
Helenr

TA贡献1780条经验 获得超3个赞

Object类不能直接实例化,直接用string类型呗,跟object不是一样嘛


查看完整回答
反对 回复 2019-05-14
?
翻翻过去那场雪

TA贡献2065条经验 获得超13个赞

debug看看其他层哪里有问题,这里贴上的代码应该没问题


查看完整回答
反对 回复 2019-05-14
  • 4 回答
  • 0 关注
  • 1640 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信