struts1.3 多文件长传 为什么总是角标越界?求解
jsp 页面关键代码:<html:form
action="/upload"
method="post"
focus="username"
enctype="multipart/form-data">
<table border="1" align="center">
<tr>
<td>用户名:</td>
<td><html:text property="username" /></td>
</tr>
<tr>
<td>上传文件A:</td>
<td><input type="file" name="upfile[0]"/></td>
</tr>
<tr>
<td>上传文件B:</td>
<td><input type="file" name="upfile[1]"/></td>
</tr>
<tr>
<td colspan="2" align="center"><html:submit value="上传"/></td>
</tr>
</table>
</html:form>
Form类 关键代码:这里的add方法总是角标越界,其index值总是获取的是上传文件的最后一个角标(如上的就是1),然后就抛异常
public void setUpfile(int index,FormFile upfile){
this.upfileList.add(index, upfile);
}
action类代码:直接 貌似还没进入Action类 就挂了
UploadForm uf = (UploadForm) form;
String username = uf.getUsername();
System.out.println("username:"+username);
List<FormFile> upfileList = uf.getUpfileList();
上传一个就好着 。 --------------------编程问答-------------------- 晚上回去 又看了下,原来在form类中的 public void setUpfile(int index,FormFile upfile){
this.upfileList.add(index, upfile);
}
中用该是 add(upfile),没有index。然偶别人有的用add(int index,FormFile upfile)可以 郁闷!
补充:Java , Web 开发