在 JSP 中上传多个文件 [英] Upload multiple files in a JSP

查看:127
本文介绍了在 JSP 中上传多个文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在一个 JSP 中上传多个文件?

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"

这是我的输入类型:

<input class="" type='file' style="display:none;" name="attachment" id="<%=q.getId()%>file"/>

这是我的行为

action="xxx.do"  method="post" enctype="multipart/form-data">

推荐答案

根据消息,Struts 正在尝试在您的 AssessmentForm 上设置一个 List,但是你的 AssessmentForm 类只有 setAttachment(FormFile).如果您将其更改为 List,Struts 将能够设置 FormFiles 的列表,您可以对其进行迭代以处理它们.

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.

这篇关于在 JSP 中上传多个文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆