struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bryan Hunt <ad...@revoltingdigits.com>
Subject Re: struts file upload strange error
Date Tue, 04 May 2004 00:13:36 GMT
Dude, send me your address and I will fed-ex you a cold beer 
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
I should have thought of that before. Thanks for your help !!!!!!!! I've 
just wasted 24 hours
on this.... If I was running linux I could have ran a packet capture but 
am on crappy
win 2000 box.

--B


Martin Cooper wrote:

>It's not a Struts bug, and it's not even a Struts-related problem. Any time
>you need to upload files, you must use a POST request with an 'enctype' of
>"multipart/form-data". Your form element should look like this:
>
><html:form action="/imageUpload.do" type="imageUploadForm"
>enctype="multipart/form-data">
>
>--
>Martin Cooper
>
>
>"Bryan Hunt" <admin@revoltingdigits.com> wrote in message
>news:4096A71B.5040606@revoltingdigits.com...
>  
>
>>Hi there list,
>>I have been trying to get the most simple file upload example working with
>>and have been receiving a strange error message that I just can't seem
>>to shake.
>>
>>Here is the basics of my action form
>>snip=
>>public class ImageUploadForm extends ActionForm {
>>    // --------------------------------------------------------- 
>>Instance Variables
>>    /** imageFile property */
>>    protected FormFile file;
>>
>>    // --------------------------------------------------------- Methods
>>
>>    public ActionErrors validate(
>>        ActionMapping mapping,
>>        HttpServletRequest request) {
>>
>>        if(file == null){
>>            System.out.println("file is empty");
>>        }
>>    return null;
>>    }
>>
>>    public FormFile getFile() {
>>        return file;
>>    }
>>
>>    public void setFile(FormFile file) {
>>        this.file = file;
>>    }
>>=snip
>>
>>Here is the basics of the action
>>snip=
>>public ActionForward execute(
>>      blah) {
>>            System.out.println("at least i managed to get called");
>>        throw new UnsupportedOperationException("Generated method
>>'execute(...)' not implemented.");
>>    }
>>=snip
>>
>>Here is the basics from my struts config file
>>snip=
>>    <form-bean name="imageUploadForm"
>>type="ie.jestate.struts.form.ImageUploadForm">
>>            <form-property name="file"
>>type="org.apache.struts.upload.FormFile" />
>>        </form-bean>
>><action
>>            attribute="imageUploadForm"
>>            input="/form/imageUpload.jsp"
>>            name="imageUploadForm"
>>            path="/imageUpload"
>>            type="ie.jestate.struts.action.ImageUploadAction"
>>            scope="request"
>>            validate="true"
>>            >
>>            <forward name="imageuploadsuccess"
>>path="/form/imageUpload.jsp" />
>>        </action>
>>=snip
>>
>>Here is the jsp file
>>
>>snip=
>><%@ page language="java"%>
>><%@ taglib uri="http://jakarta.apache.org/struts/tags-bean"
>>    
>>
>prefix="bean"%>
>  
>
>><%@ taglib uri="http://jakarta.apache.org/struts/tags-html"
>>    
>>
>prefix="html"%>
>  
>
>><html>
>>    <head>
>>        <title>JSP for imageUploadForm form</title>
>>    </head>
>>    <body>
>>        <DEFANGED_html:form action="/imageUpload.do" type="imageUploadForm" >
>>            File :
>>              <DEFANGED_html:file property="file"/>
>>            <DEFANGED_html:submit/>
>>        </DEFANGED_html:form>
>>    <body>
>>    </html>
>>=snip
>>
>>And here is the abreviated version of the error message
>>snip=
>>
>>*exception*
>>
>>javax.servlet.ServletException: BeanUtils.populate
>>org.apache.struts.util.RequestUtils.populate(RequestUtils.java:1254)
>>
>>    
>>
>org.apache.struts.action.RequestProcessor.processPopulate(RequestProcessor.j
>ava:821)*
>  
>
>>cause mère*
>>
>>java.lang.IllegalArgumentException: argument type mismatch
>>sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>>=snip
>>
>>I have tried changing the type to text and the type to String in
>>the form and that works but use this FormFile class and everything
>>seems to go fubar.
>>
>>
>>It never even gets to call the action , instead it generates this error
>>message ,
>>but the setters and getters are right and the variable is public, this
>>only happens
>>with the FormFile. All the struts stuff is in my classpath as is
>>commons-fileupload-1.0.jar.
>>
>>Anyone got any idea what the hell I'm doing wrong ... I'm starting to
>>suspect this
>>could be a struts bug cause everything looks straightforward enough.
>>
>>--B
>>    
>>
>
>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>For additional commands, e-mail: user-help@struts.apache.org
>
>  
>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Mime
View raw message