Java 如何在struts 1.x中使用多个输入文件上载图像?(参数类型不匹配)
我在论坛上看到过很多这样的问题,但都没有答案。 我有代码,上传一个,只有一个,图像到服务器。但现在我需要上传更多。所以,我改变了反标签输入文件的输入文件多,但我不能使其工作 我的表格:Java 如何在struts 1.x中使用多个输入文件上载图像?(参数类型不匹配),java,file,struts-1,Java,File,Struts 1,我在论坛上看到过很多这样的问题,但都没有答案。 我有代码,上传一个,只有一个,图像到服务器。但现在我需要上传更多。所以,我改变了反标签输入文件的输入文件多,但我不能使其工作 我的表格: <form name="frmMain" id="frmMain" action="COMPL_UPDATE_ACTION" method="post" enctype="multipart/form-data"> <input type="file" name="image_path" mu
<form name="frmMain" id="frmMain" action="COMPL_UPDATE_ACTION" method="post" enctype="multipart/form-data">
<input type="file" name="image_path" multiple />
</form>
我试过很多方法,但都不管用。怎么了?或者?我如何上传多个输入文件的图像
谢谢你 我几年前就研究过这个,但在Struts 1中永远无法使用它。这让我很难过s
public class UploadPhotoForm extends BasicBudgetForm {
protected ArrayList<FormFile> objcImagePath = new ArrayList<FormFile>();
public UploadPhotoForm() {
super();
}
public int getTamano() {
return objcImagePath.size();
}
public List<FormFile> getImagePath() {
return objcImagePath;
}
public void setImagePath(List<FormFile> file) {
objcImagePath.addAll(file);
}
}
private void processPicture(
UploadPhotoForm objaForm,
HttpServletRequest objaRequest,
BudgetInterface objaBudget
)
throws CVIException {
ArrayList<FormFile> objlFile = null;
List lstlPictures = null;
List lstlPathPictures = null;
List lstlLastPictures = null;
String slFilename = null;
if ((objaForm==null) || (objaRequest==null) || (objaBudget==null)) {
throw new CVIException("bla bla bla");
}
lstlPictures = objaBudget.getPictureList();
lstlLastPictures = (
(List) objaRequest.getSession()
.getAttribute(Constants.IMAGE)
);
if (lstlLastPictures==null) {
lstlLastPictures = new ArrayList();
}
//This is what is important to me
for(int i = 0; i < objaForm.getTamano(); i++){
objlFile = (ArrayList<FormFile>) objaForm.getImagePath();
slFilename = uploadPicture(objlFile.get(i));
lstlPictures.add(
SelectItemFactory.create(
"",
slFilename,
false
)
);
}
java.lang.IllegalArgumentException: Cannot invoke com.multiasistencia.cvi.controller.forms.UploadPhotoForm.setImagePath - argument type mismatch