ognl.MethodFailedException: Method "

在使用Struts2框架时遇到ognl.MethodFailedException异常,表现为找不到POJO中已定义的方法,原因是方法参数类型不匹配。本文介绍了具体的错误信息及解决办法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

Struts2 报错,极度郁闷了
下面我就只贴出关键错误信息出来,帖多了也是无用;
ognl.MethodFailedException: Method "setAsLimbsCause" failed for object com.zhi.ds.pojo.ClAssess@1192e9 [java.lang.NoSuchMethodException: setAsLimbsCause([Ljava.lang.String;)]
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:823)

java.lang.NoSuchMethodException: setAsLimbsCause([Ljava.lang.String;)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:810)


这是我在一个页面上填写信息后,点击提交保存后报错的;
上面的错误信息真是搞不懂了。那个方法明明就在pojo中定义了,却硬要说没这个方法。而且

setAsLimbsCause([Ljava.lang.String;) 这个地方,中的参数,定义的是 Short类型,可显示却为String,还在Java前面加个L。总共报了很多个字段的错误,而且全都是一个错误模式。极度郁闷........



解决方法:

参数类型不匹配。pojo全部改用string,在处理类里面去改类型就没这么多麻烦啦 

2025-04-01 10:40:39.119 TRACE [org.springframework.web.method.HandlerMethod] - Arguments: [org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'null != deviceNo and deviceNo.size() > 0'. Cause: org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object false [java.lang.NoSuchMethodException: java.lang.String.size()]] org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'null != deviceNo and deviceNo.size() > 0'. Cause: org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object false [java.lang.NoSuchMethodException: java.lang.String.size()] at org.mybatis.spring.MyBatisExceptionTranslator.translateExceptionIfPossible(MyBatisExceptionTranslator.java:96) at org.mybatis.spring.SqlSessionTemplate$SqlSessionInterceptor.invoke(SqlSessionTemplate.java:441) at com.sun.proxy.$Proxy100.selectList(Unknown Source) at org.mybatis.spring.SqlSessionTemplate.selectList(SqlSessionTemplate.java:224) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.executeForMany(MybatisMapperMethod.java:166) at com.baomidou.mybatisplus.core.override.MybatisMapperMethod.execute(MybatisMapperMethod.java:77) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy$PlainMethodInvoker.invoke(MybatisMapperProxy.java:148) at com.baomidou.mybatisplus.core.override.MybatisMapperProxy.invoke(MybatisMapperProxy.java:89) at com.sun.proxy.$Proxy119.timePeriodTraffic(Unknown Source) at com.syzn.dv.biz.yunk.southbound.adapter.repo.impl.YunkStatisticDataRepoImpl.timePeriodTraffic(YunkStatisticDataRepoImpl.java:145) at com.syzn.dv.biz.yunk.manager.impl.YunkBigScreenManagerImpl.getTimePeriodTraffic(YunkBigScreenManagerImpl.java:120) at com.syzn.dv.biz.yunk.northbound.appservice.impl.YunkBigScreenAppServiceImpl.getTimePeriodTraffic(YunkBigScreenAppServiceImpl.java:58) at com.syzn.dv.biz.big
04-02
025-04-01 11:29:39.500 TRACE [org.springframework.web.servlet.DispatcherServlet] - GET "/big-screen/get-time-period-traffic?deviceType=3", parameters={masked}, headers={masked} in DispatcherServlet 'dispatcherServlet' 2025-04-01 11:29:39.502 TRACE [o.s.w.s.m.m.a.RequestMappingHandlerMapping] - Mapped to com.syzn.dv.biz.bigscreen.northbound.controller.BigScreenController#getTimePeriodTraffic(BigScreenCommonReq) 2025-04-01 11:29:39.527 TRACE [org.springframework.web.method.HandlerMethod] - Arguments: [BigScreenCommonReq(direction=null, deviceType=3, startDate=null, endDate=null)] 2025-04-01 11:29:39.539 DEBUG [org.mybatis.spring.SqlSessionUtils] - Creating a new SqlSession 2025-04-01 11:29:39.544 DEBUG [org.mybatis.spring.SqlSessionUtils] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7caa55e8] was not registered for synchronization because synchronization is not active 2025-04-01 11:29:39.565 DEBUG [org.mybatis.spring.SqlSessionUtils] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7caa55e8] 2025-04-01 11:29:39.567 DEBUG [o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver] - Using @ExceptionHandler com.syzn.dv.config.GlobalExceptionHandler#customErrorHandler(RuntimeException) 2025-04-01 11:29:39.568 TRACE [org.springframework.web.method.HandlerMethod] - Arguments: [org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'null != deviceNo and deviceNo.size() > 0'. Cause: org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object false [java.lang.NoSuchMethodException: java.lang.String.size()]] org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'null != deviceNo and deviceNo.size() > 0'. Cause: org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object false [java.lang.NoSuchMethodException: java.lang.String.si
最新发布
04-02
2025-04-01 10:44:22.043 TRACE [org.springframework.web.servlet.DispatcherServlet] - GET "/big-screen/get-time-period-traffic?deviceType=3", parameters={masked}, headers={masked} in DispatcherServlet 'dispatcherServlet' 2025-04-01 10:44:22.046 TRACE [o.s.w.s.m.m.a.RequestMappingHandlerMapping] - Mapped to com.syzn.dv.biz.bigscreen.northbound.controller.BigScreenController#getTimePeriodTraffic(BigScreenCommonReq) 2025-04-01 10:44:22.075 TRACE [org.springframework.web.method.HandlerMethod] - Arguments: [BigScreenCommonReq(direction=null, deviceType=3, startDate=null, endDate=null)] 2025-04-01 10:44:22.090 DEBUG [org.mybatis.spring.SqlSessionUtils] - Creating a new SqlSession 2025-04-01 10:44:22.097 DEBUG [org.mybatis.spring.SqlSessionUtils] - SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7b1f52cf] was not registered for synchronization because synchronization is not active 2025-04-01 10:44:22.125 DEBUG [org.mybatis.spring.SqlSessionUtils] - Closing non transactional SqlSession [org.apache.ibatis.session.defaults.DefaultSqlSession@7b1f52cf] 2025-04-01 10:44:22.129 DEBUG [o.s.w.s.m.m.a.ExceptionHandlerExceptionResolver] - Using @ExceptionHandler com.syzn.dv.config.GlobalExceptionHandler#customErrorHandler(RuntimeException) 2025-04-01 10:44:22.129 TRACE [org.springframework.web.method.HandlerMethod] - Arguments: [org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'null != deviceNo and deviceNo.size() > 0'. Cause: org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object false [java.lang.NoSuchMethodException: java.lang.String.size()]] org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.builder.BuilderException: Error evaluating expression 'null != deviceNo and deviceNo.size() > 0'. Cause: org.apache.ibatis.ognl.MethodFailedException: Method "size" failed for object false [java.lang.NoSuchMethodException: java.lang.String.s
04-02
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值