大家好,我试了两天
Struts2.18 myEclipse8.0
我自定义了一个类型转换器[code="java"]
public Object convertFromString(Map arg0, String[] arg1, Class arg2) {
Integer inte=null;
for(int i=0;i<arg1.length;i++)
{
String [] tempStr = arg1[i].split("-");
StringBuilder sb = new StringBuilder();
for(int j=0;j< tempStr.length;j++)
sb.append(tempStr[j]);
inte =new Integer(sb.toString());
}
return inte;}
[/code]
当我传入正确的参数时 他能正常的工作 但是当我输入字母时 如aaa 时.后台就会打印一大条的错误
ognl.MethodFailedException: Method "setId" failed for object com.wugang.User@1e9c82e [java.lang.NoSuchMethodException: com.wugang.User.setId([Ljava.lang.String;)]
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1265)
at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454)
at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301).....
java.lang.NoSuchMethodException: com.wugang.User.setId([Ljava.lang.String;)
at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1206)
at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1454)
at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85)
at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162)
at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:28)
at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2225)
at ognl.ASTProperty.setValueBody(ASTProperty.java:127)
at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220)
at ognl.SimpleNode.setValue(SimpleNode.java:301)
at ognl.ASTChain.setValueBody(ASTChain.java:227)
当然 我应用了conversionError 拦截器 而且filederrors 字段里有错误的信息 但为什么后台还有错误呢 不是被拦截器捕获了后台就应该没有错了么 还是我自己理解错了 求大家帮帮我