Upload multiple files in a JSP

北城以北 提交于 2019-12-10 12:07:18

问题


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">

回答1:


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.



来源:https://stackoverflow.com/questions/17609403/upload-multiple-files-in-a-jsp

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!