views:

67

answers:

1

I have a Struts 1 application with the following ActionForm:

import org.apache.struts.upload.FormFile;

public class uploadedFileForm {

public FormFile theFile;

    public FormFile getTheFile() {
        return theFile;
    }

    public void setTheFile(FormFile theFile) {
        this.theFile = theFile;
    }
}

My JSP page has the following form:

<html:form action="/myAction" enctype="multipart/form-data">
<html:file property="theFile" onkeypress="return false;" />
</html:form>

When I submit the form to my Struts action, I immediately receive the following error message:

org.apache.commons.beanutils.ConversionException: Could not convert java.lang.String to org.apache.struts.upload.FormFile 

I tried adding some debug statements to the beginning of my Action, but none of them printed out. This seems to indicate that Struts is throwing this error before reaching my action.

Does anyone have any suggestion about what might be causing this error message?

A: 

The problem was related to the html:form tag.

I needed to have both method="post" and enctype="multipart/form-data" attributes on the html:form tag.

My actual form was more complex and didn't have the enctype="multipart/form-data" property. When I added it, everything worked fine.

David