You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Flo <fl...@free.fr> on 2003/06/26 18:40:16 UTC
Upload Error
I applied the folowing example to my project but a get an error :
java.lang.NoClassDefFoundError: org/apache/commons/fileupload/FileUploadException
at java.lang.Class.getDeclaredConstructors0(Native Method)
at java.lang.Class.privateGetDeclaredConstructors(Class.java:1590)
at java.lang.Class.getConstructor0(Class.java:1762)
at java.lang.Class.newInstance0(Class.java:276)
at java.lang.Class.newInstance(Class.java:259)
http://jakarta.apache.org/struts/faqs/actionForm.html
<%@page language="java">
<%@taglib
uri="/WEB-INF/struts-html.tld"
prefix="html">
<html:form action="uploadAction.do" enctype="multipart/form-data">
Please Input Text: <html:text property="myText">
Please Input The File You Wish to Upload: <html:file property="myFile">
<html:submit />
</html:form>
--------------------------------------------------------------------------------
The next step is to create your ActionForm bean:
--------------------------------------------------------------------------------
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;
import org.apache.struts.upload.FormFile;
public class UploadForm extends ActionForm {
protected String myText;
protected FormFile myFile;
public void setMyText(String text) {
myText = text;
}
public String getMyText() {
return myText;
}
public void setMyFile(FormFile file) {
myFile = file;
}
public FormFile getMyFile() {
return myFile;
}
}