当前位置: 代码迷 >> J2EE >> ognl.MethodFailedException: Method "setFile" failed for object
  详细解决方案

ognl.MethodFailedException: Method "setFile" failed for object

热度:2636   发布时间:2016-04-22 02:44:07.0
struts2上传文件报的错
2010-7-11 13:44:32 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Struts has detected a file upload UI tag (s:file) being used without a form set to enctype 'multipart/form-data'. This is probably an error!
2010-7-11 13:44:32 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Struts has detected a file upload UI tag (s:file) being used without a form set to method 'POST'. This is probably an error!
2010-7-11 13:44:44 com.opensymphony.xwork2.util.logging.commons.CommonsLogger warn
警告: Error setting expression 'file' with value '[Ljava.lang.String;@19f410'
ognl.MethodFailedException: Method "setFile" failed for object com.action.UploadAction@1f87254 [java.lang.NoSuchMethodException: com.action.UploadAction.setFile([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 com.opensymphony.xwork2.ognl.accessor.CompoundRootAccessor.setProperty(CompoundRootAccessor.java:65)
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.Ognl.setValue(Ognl.java:737)
at com.opensymphony.xwork2.ognl.OgnlUtil.setValue(OgnlUtil.java:198)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:161)
at com.opensymphony.xwork2.ognl.OgnlValueStack.setValue(OgnlValueStack.java:149)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.setParameters(ParametersInterceptor.java:276)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:187)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)
at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:237)
at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:195)
at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:87)

------解决方案--------------------
without a form set to enctype 'multipart/form-data'.

要设置form的enctype。
------解决方案--------------------
<s:form action="admin/addImageItems.do" method="post" enctype="multipart/form-data">
加上红色字体那部分
------解决方案--------------------
探讨
<s:form action="admin/addImageItems.do" method="post" enctype="multipart/form-data">
加上红色字体那部分
  相关解决方案