提示错误:The constructor FileInputStream(File) is undefined

用Struts2上传文件,报错如下:

警告: Error setting expression 'upload' with value '[Ljava.io.File;@69c67db'
ognl.MethodFailedException: Method "setUpload" failed for object com.teng.action.UploadAction@3e2f1b1a [java.lang.NoSuchMethodException: com.teng.action.UploadAction.setUpload([Ljava.io.File;)]
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)


Action中有 FileInputStream in= new FileInputStream (this.getUpload()[i]);


提示错误:The constructor FileInputStream(File) is undefined


原因:引入文件出错,将import org.apache.struts2.components.File;改为import java.io.File;即可。

你可能感兴趣的:(struts2)