ognl.MethodFailedException: Method "setXX" failed for object

由于数据类型不匹配而导致的异常

ognl.MethodFailedException: Method "setId" failed for object cn.xyurp.system.bean.DomainValue@1a6d030 [java.lang.NoSuchMethodException: setId([Ljava.lang.String;)] at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:823) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:964) at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:75) at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:131) at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:1656) at ognl.ASTProperty.setValueBody(ASTProperty.java:101) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.ASTChain.setValueBody(ASTChain.java:172) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:177) at ognl.SimpleNode.setValue(SimpleNode.java:246) at ognl.Ognl.setValue(Ognl.java:476) at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:198)

 

可以debug 通过查看 ognl.Ognl.java 类中的setValue()源代码 查找问题

 

public static void setValue( Object tree, Map context, Object root, Object value ) throws OgnlException { OgnlContext ognlContext = (OgnlContext)addDefaultContext(root, context); Node n = (Node) tree; n.setValue( ognlContext, root, value ); } // n 既是 JSP页面 form 表单中的 input 元素 的name 属性 比如 <input name="user.username" value="123"/> 然后在 ognl 中 通过action 中的 setter 方法 将调用 ognl.Ognl.java 中的 上述方法: n ==> user.username value ==> 123

 

你可能感兴趣的:(jsp,object,tree,input,action,setter)