标题:使用beanutils 封装出错,怎么解决?
只看楼主
米团
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2016-4-6
结帖率:33.33%
已结贴  问题点数:10 回复次数:4 
使用beanutils 封装出错,怎么解决?
//c.手动封装product
                Product p = new Product();
                BeanUtils.populate(p, map);
                oi.setProduct(p);

java.lang.IllegalArgumentException: java.lang.ClassCastException@57bf5ee7
    at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.(PropertyUtils.java:1789)
    at com.(PropertyUtils.java:1684)
    at com.(PropertyUtils.java:1713)
    at com.(BeanUtils.java:1019)
    at com.(BeanUtils.java:808)
    at cn.hl.dao.impl.OrderDaoImpl.findMyOrdersByPage(OrderDaoImpl.java:86)
    at cn.hl.service.impl.OrderServiceImpl.findMyOrdersByPage(OrderServiceImpl.java:60)
    at cn.hl.web.servlet.OrderServlet.findMyOrdersByPage(OrderServlet.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at cn.hl.web.servlet.base.BaseServlet.service(BaseServlet.java:21)
    at javax.servlet.http.HttpServlet.service(HttpServlet.java:723)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at cn.hl.filter.EncodingFilter.doFilter(EncodingFilter.java:34)
    at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:235)
    at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
    at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:103)
    at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:293)
    at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:859)
    at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:610)
    at org.apache.tomcat.(JIoEndpoint.java:503)
    at java.lang.Thread.run(Thread.java:619)

搜索更多相关主题的帖子: java lang sun invoke apache 
2018-06-25 18:04
静水且流深
Rank: 5Rank: 5
等 级:贵宾
威 望:11
帖 子:60
专家分:319
注 册:2017-7-7
得分:4 
java.lang.IllegalArgumentException: java.lang.ClassCastException@57bf5ee7
    at sun.reflect.GeneratedMethodAccessor44.invoke(Unknown Source)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at com.(PropertyUtils.java:1789)
    at com.(PropertyUtils.java:1684)
    at com.(PropertyUtils.java:1713)
    at com.(BeanUtils.java:1019)
    at com.(BeanUtils.java:808)
    at cn.hl.dao.impl.OrderDaoImpl.findMyOrdersByPage(OrderDaoImpl.java:86)
    at cn.hl.service.impl.OrderServiceImpl.findMyOrdersByPage(OrderServiceImpl.java:60)
    at cn.hl.web.servlet.OrderServlet.findMyOrdersByPage(OrderServlet.java:49)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)

不过是爱情,又能走多久
2018-06-25 21:47
米团
Rank: 1
等 级:新手上路
帖 子:6
专家分:0
注 册:2016-4-6
得分:0 
回复 2楼 静水且流深
就是上面那三行代码出错的地方,怎么改?
2018-06-25 22:22
疯狂的小a
Rank: 10Rank: 10Rank: 10
等 级:贵宾
威 望:39
帖 子:423
专家分:1871
注 册:2018-2-6
得分:4 
java.lang.IllegalArgumentException: java.lang.ClassCastException@57bf5ee7
类型转换错误,如果map里面的key和product的属性对应的应该可以封装数据,你把map的打印看一下

假如人生没有梦想,和咸鱼有什么区别!
2018-06-26 21:49
林月儿
Rank: 16Rank: 16Rank: 16Rank: 16
来 自:湖南
等 级:版主
威 望:138
帖 子:2276
专家分:10647
注 册:2015-3-19
得分:4 
什么都没看到,还问别人怎么改?
作业吗?

剑栈风樯各苦辛,别时冰雪到时春
2018-06-26 22:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-488148-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.093965 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved