ognl.MethodFailedException:

本文详细阐述了在使用Struts2处理表单数据时遇到的转型错误问题,即当表单部分字段未被填入时,如何避免Ognl.MethodFailedException异常的出现。提出了通过确保所有字段被正确填充、设置默认值或使用其他标签等方法来解决此问题。

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

今天用struts2时遇到了这么个问题:

WARNING: Error setting expression 'XXX' with value '[Ljava.lang.String;@28da27'

ognl.MethodFailedException: Method "setXXX" failed for object

....
Caused by: java.lang.NoSuchMethodException: XXX.action.XXXAction.setXXX([Ljava.lang.String;)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
... 63 more
/-- Encapsulated exception ------------\

  • 简单描述一下问题,jsp中写了几个想输入int类型的框标签,联合查询嘛;只要表单没有全部输入,就会报上述错误。
  • 仔细想了一下,struts2帮咱们转型这是一定的,可是你若是不填写其中一个表单的话,那就是说action其中一个属性对应的值是"",就是空字符串。
  • 这样的话,struts2当然就无法帮你转成你想转成的的int或者其他非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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值