Reputation: 21
How to upload multiple files in a JSP?
I have a list of eight Questions, I want attachments for each question, when I am submitting the form I am getting the following error. Please help me in solving this
"Caused by: java.lang.IllegalArgumentException: Cannot invoke
com.usrinfo.form.AssessmentForm.setAttatchment on bean class
'class com.usrinfo.form.AssessmentForm' - argument type mismatch -
had objects of type "java.util.ArrayList" but expected
signature "org.apace.struts.upload.FormFile"
this is my input type:
<input class="" type='file' style="display:none;" name="attachment" id="<%=q.getId()%>file"/>
This is my action
action="xxx.do" method="post" enctype="multipart/form-data">
Upvotes: 0
Views: 1750
Reputation: 9705
According to the message, Struts is trying to set a List<FormFile>
on your AssessmentForm
, but your AssessmentForm
class only has setAttachment(FormFile)
. If you change it to List<FormFile>
, Struts will be able to set the list of FormFiles
and you can iterate over that to process them.
Upvotes: 1