Struts2报错异常Method "setUser" failed for object com.mikey.action.ConverterAction@dd34285
在写类型转换的时候发现报错
异常信息
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 ognl.MethodFailedException: Method "setUser" failed for object com.mikey.action.ConverterAction@dd34285 [java.lang.NoSuchMethodException: com.mikey.action.ConverterAction.setUser([Ljava.lang.String;)] 2 at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1292) 3 at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1481) 4 at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85) 5 at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162) 6 at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27) 7 at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2318) 8 at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:77) 9 at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2318) 10 at ognl.ASTProperty.setValueBody(ASTProperty.java:127) 11 at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) 12 at ognl.SimpleNode.setValue(SimpleNode.java:301) 13 at ognl.Ognl.setValue(Ognl.java:737) 14 at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:217) 15 at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:186) 16 at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:173) 17 at com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter(OgnlValueStack.java:151) 18 at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:292) 19 at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:203) 20 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 21 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 22 at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211) 23 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 24 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 25 at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190) 26 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 27 at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) 28 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 29 at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90) 30 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 31 at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243) 32 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 33 at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) 34 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 35 at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) 36 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 37 at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145) 38 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 39 at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171) 40 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 41 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 42 at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176) 43 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 44 at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) 45 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 46 at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192) 47 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 48 at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187) 49 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 50 at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54) 51 at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510) 52 at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) 53 at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) 54 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 55 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 56 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 57 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 58 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) 59 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 60 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) 61 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) 62 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 63 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) 64 at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) 65 at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 66 at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789) 67 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437) 68 at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 69 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 70 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 71 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 72 at java.lang.Thread.run(Thread.java:745) 73 Caused by: java.lang.NoSuchMethodException: com.mikey.action.ConverterAction.setUser([Ljava.lang.String;) 74 at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1233) 75 ... 70 more 76 /-- Encapsulated exception ------------\ 77 java.lang.NoSuchMethodException: com.mikey.action.ConverterAction.setUser([Ljava.lang.String;) 78 at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1233) 79 at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1481) 80 at ognl.ObjectPropertyAccessor.setPossibleProperty(ObjectPropertyAccessor.java:85) 81 at ognl.ObjectPropertyAccessor.setProperty(ObjectPropertyAccessor.java:162) 82 at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty(ObjectAccessor.java:27) 83 at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2318) 84 at com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:77) 85 at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2318) 86 at ognl.ASTProperty.setValueBody(ASTProperty.java:127) 87 at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) 88 at ognl.SimpleNode.setValue(SimpleNode.java:301) 89 at ognl.Ognl.setValue(Ognl.java:737) 90 at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:217) 91 at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue(OgnlValueStack.java:186) 92 at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:173) 93 at com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter(OgnlValueSt 94 ack.java:151) 95 at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:292) 96 at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:203) 97 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 98 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 99 at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:211) 100 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 101 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 102 at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:190) 103 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 104 at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:75) 105 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 106 at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:90) 107 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 108 at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:243) 109 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 110 at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) 111 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 112 at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) 113 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 114 at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145) 115 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 116 at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171) 117 at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) 118 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 119 at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:176) 120 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 121 at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) 122 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 123 at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:192) 124 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 125 at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:187) 126 at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:249) 127 at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54) 128 at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:510) 129 at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77) 130 at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:91) 131 at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:192) 132 at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:165) 133 at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:198) 134 at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) 135 at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:474) 136 at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:140) 137 at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) 138 at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:624) 139 at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:87) 140 at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:349) 141 at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:783) 142 at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) 143 at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:789) 144 at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1437) 145 at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) 146 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) 147 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) 148 at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) 149 at java.lang.Thread.run(Thread.java:745) 150 \--------------------------------------/
报错原因
没有正确配置xwork-conversion.properties文件,并且要把文件放在src文件夹下
解决方法
添加文件正确配置即可
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 com.mikey.bean.User=com.mikey.converter.UserConverter 2 java.util.List=com.mikey.converter.ListConverter
合群是堕落的开始 优秀的开始是孤行