struts2中文件上传出错!
2013-4-6 20:31:12 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn 警告: Error setting expression 'uploadfile' with value
'[Ljava.lang.String;@10eaeda' ognl.MethodFailedException: Method "setUploadfile" failed for object
com.upload.action.UploadAction@14362d9 [java.lang.NoSuchMethodException:
com.upload.action.UploadAction.setUploadfile([Ljava.lang.String;)] at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1289) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1478) at ognl.ObjectPropertyAccessor.setPossibleProperty
(ObjectPropertyAccessor.java:85) at ognl.ObjectPropertyAccessor.setProperty
(ObjectPropertyAccessor.java:162) at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty
(ObjectAccessor.java:27) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2315) at
com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty
(CompoundRootAccessor.java:77) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2315) at ognl.ASTProperty.setValueBody(ASTProperty.java:127) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) at ognl.SimpleNode.setValue(SimpleNode.java:301) at ognl.Ognl.setValue(Ognl.java:737) at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:217) at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue
(OgnlValueStack.java:186) at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue
(OgnlValueStack.java:173) at com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter
(OgnlValueStack.java:151) at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters
(ParametersInterceptor.java:317) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept
(ParametersInterceptor.java:228) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept
(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept
(ParametersInterceptor.java:236) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept
(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept
(StaticParametersInterceptor.java:190) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept
(MultiselectInterceptor.java:75) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept
(CheckboxInterceptor.java:90) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept
(FileUploadInterceptor.java:243) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept
(ModelDrivenInterceptor.java:100) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept
(ScopedModelDrivenInterceptor.java:141) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept
(ChainingInterceptor.java:145) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept
(PrepareInterceptor.java:171) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept
(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept
(I18nInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept
(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept
(AliasInterceptor.java:192) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept
(ExceptionMappingInterceptor.java:187) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at org.apache.struts2.impl.StrutsActionProxy.execute
(StrutsActionProxy.java:54) at org.apache.struts2.dispatcher.Dispatcher.serviceAction
(Dispatcher.java:511) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction
(ExecuteOperations.java:77) at
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter
(StrutsPrepareAndExecuteFilter.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:602) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run
(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662) Caused by: java.lang.NoSuchMethodException:
com.upload.action.UploadAction.setUploadfile([Ljava.lang.String;) at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1230) ... 63 more /-- Encapsulated exception ------------\ java.lang.NoSuchMethodException: com.upload.action.UploadAction.setUploadfile
([Ljava.lang.String;) at ognl.OgnlRuntime.callAppropriateMethod(OgnlRuntime.java:1230) at ognl.OgnlRuntime.setMethodValue(OgnlRuntime.java:1478) at ognl.ObjectPropertyAccessor.setPossibleProperty
(ObjectPropertyAccessor.java:85) at ognl.ObjectPropertyAccessor.setProperty
(ObjectPropertyAccessor.java:162) at com.opensymphony.xwork2.ognl.accessor.ObjectAccessor.setProperty
(ObjectAccessor.java:27) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2315) at
com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty
(CompoundRootAccessor.java:77) at ognl.OgnlRuntime.setProperty(OgnlRuntime.java:2315) at ognl.ASTProperty.setValueBody(ASTProperty.java:127) at ognl.SimpleNode.evaluateSetValueBody(SimpleNode.java:220) at ognl.SimpleNode.setValue(SimpleNode.java:301) at ognl.Ognl.setValue(Ognl.java:737) at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:217) at com.opensymphony.xwork2.ognl.OgnlValueStack.trySetValue
(OgnlValueStack.java:186) at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue
(OgnlValueStack.java:173) at com.opensymphony.xwork2.ognl.OgnlValueStack.setParameter
(OgnlValueStack.java:151) at
com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters
(ParametersInterceptor.java:317) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept
(ParametersInterceptor.java:228) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept
(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept
(ParametersInterceptor.java:236) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept
(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at
com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept
(StaticParametersInterceptor.java:190) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept
(MultiselectInterceptor.java:75) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept
(CheckboxInterceptor.java:90) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept
(FileUploadInterceptor.java:243) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept
(ModelDrivenInterceptor.java:100) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at
com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept
(ScopedModelDrivenInterceptor.java:141) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept
(ChainingInterceptor.java:145) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept
(PrepareInterceptor.java:171) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept
(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept
(I18nInterceptor.java:176) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept
(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept
(AliasInterceptor.java:192) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept
(ExceptionMappingInterceptor.java:187) at com.opensymphony.xwork2.DefaultActionInvocation.invoke
(DefaultActionInvocation.java:249) at org.apache.struts2.impl.StrutsActionProxy.execute
(StrutsActionProxy.java:54) at org.apache.struts2.dispatcher.Dispatcher.serviceAction
(Dispatcher.java:511) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction
(ExecuteOperations.java:77) at
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter
(StrutsPrepareAndExecuteFilter.java:91) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter
(ApplicationFilterChain.java:235) at org.apache.catalina.core.ApplicationFilterChain.doFilter
(ApplicationFilterChain.java:206) at org.apache.catalina.core.StandardWrapperValve.invoke
(StandardWrapperValve.java:233) at org.apache.catalina.core.StandardContextValve.invoke
(StandardContextValve.java:191) at org.apache.catalina.core.StandardHostValve.invoke
(StandardHostValve.java:127) at org.apache.catalina.valves.ErrorReportValve.invoke
(ErrorReportValve.java:102) at org.apache.catalina.core.StandardEngineValve.invoke
(StandardEngineValve.java:109) at org.apache.catalina.connector.CoyoteAdapter.service
(CoyoteAdapter.java:293) at org.apache.coyote.http11.Http11Processor.process
(Http11Processor.java:859) at org.apache.coyote.http11.Http11Protocol
$Http11ConnectionHandler.process(Http11Protocol.java:602) at org.apache.tomcat.util.net.JIoEndpoint$Worker.run
(JIoEndpoint.java:489) at java.lang.Thread.run(Thread.java:662) \--------------------------------------/
原因是: 问题:form表单以二进制的方式查询,需要设置enctype=“multipart/form-data”
出现该问题的环境:使用文件上传的时候,忘记设置了form表单的enctype属性为
multipart/form-data
posted on 2013-04-06 20:55 Software_King 阅读(340) 评论(0) 编辑 收藏 举报