In my jsp i have a html:file
like this, and in the form i have the getter and setter. but when running i got
Caused by: java.lang.IllegalArgumentException: Cannot invoke com.app.app.struts.forms.MyForm.setDocfile on bean class 'class com.app.app.struts.forms.MyForm'
- argument type mismatch - had objects of type "java.lang.String" but expected signature "org.apache.struts.upload.FormFile"
jsp:
<html:file property="docfile" styleId="docfile" size="45" ></html:file>
getting the error only when submitting the page and i'm not uploading anything. (the upload field is not a required filed .)
It seems to be problem with the encoding, the struts form doesn't recognize the submit as a type of file, make sure to set the form's enctype attribute to multipart/form-data
and method as post
.
So you should have:
<html:form action="/somePath" enctype="multipart/form-data" method="post"></html:form>
Be aware that this could mess up things with your validation. See this thread for more.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With