使用HashMap了
JSP:
java 代码
<input maxlength="2147483647" name="contentFile[0]" size="50" type="file">
<input maxlength="2147483647" name="contentFile[1]" size="50" type="file">
...
ActionForm:
private Map files = new HashMap();
/**
* @return Returns the File Count.
*/
public int getFileCount() {
return files.size();
}
public void setFileCount(int fileCount) {
this.fileCount = fileCount;
}
/**
* @return Returns the Content .
*/
public FormFile getContentFile(int key){
return (FormFile)files.get(new Integer(key));
}
public void setContentFile(int key,FormFile value){
files.put(new Integer(key),value);
}
Action:
form.getContentFile(i).getFileName()
本文介绍了一种使用JSP和HashMap实现多文件上传的方法。通过定义ActionForm中的HashMap来存储上传文件,并提供了一系列用于获取和设置文件的方法。此外,还展示了如何在JSP页面上设置多个文件输入框。

被折叠的 条评论
为什么被折叠?



