如何在JSP中上传多个文件?
我有八个问题的列表,我想要每个问题的附件,当我提交表单时,我收到以下错误。请帮我解决这个问题
"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"
这是我的输入类型:
<input class="" type='file' style="display:none;" name="attachment" id="<%=q.getId()%>file"/>
这是我的行动
action="xxx.do" method="post" enctype="multipart/form-data">
答案 0 :(得分:1)
根据消息,Struts正试图在List<FormFile>
上设置AssessmentForm
,但您的AssessmentForm
课程只有setAttachment(FormFile)
。如果您将其更改为List<FormFile>
,Struts将能够设置FormFiles
的列表,您可以对其进行迭代以处理它们。