请问如何用struts上传多个多个文件?? 我刚好做过一个这样的东西,大概思路是将每次上传的文件保存在session中,然后一并提交完成 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 ByteArrayOutputStream baosLicence = new ByteArrayOutputStream(); ByteArrayOutputStream baostaxLicence = new ByteArrayOutputStream(); ByteArrayOutputStream baosorganiseNo = new ByteArrayOutputStream(); try { InputStream streamLicence = provider.getLicence().getInputStream(); InputStream streamtaxLicence = provider.getTaxLicence().getInputStream(); InputStream streamorganiseNo = provider.getOrganiseNo().getInputStream(); //taxLicence byte[] bufferLicence = new byte[8192]; int bytesReadLicence = 0; while ((bytesReadLicence = streamLicence.read(bufferLicence, 0, 8192)) != -1) { baosLicence.write(bufferLicence, 0, bytesReadLicence); } //taxLicence byte[] buffertaxLicence = new byte[8192]; int bytesReadtaxLicence = 0; while ((bytesReadtaxLicence = streamtaxLicence.read(buffertaxLicence, 0, 8192)) != -1) { baostaxLicence.write(buffertaxLicence, 0, bytesReadtaxLicence); } //organiseNo byte[] bufferorganiseNo = new byte[8192]; int bytesReadorganiseNo = 0; while ((bytesReadorganiseNo = streamorganiseNo.read(bufferorganiseNo, 0, 8192)) != -1) { baosorganiseNo.write(bufferorganiseNo, 0, bytesReadorganiseNo); } ps.setBinaryStream(11,new ByteArrayInputStream(baosLicence.toByteArray()),baosLicence.toByteArray().length); System.out.println(provider.getLicence().getFileSize()); ps.setBinaryStream(12,new ByteArrayInputStream(baostaxLicence.toByteArray()),baostaxLicence.toByteArray().length); System.out.println(provider.getTaxLicence().getFileSize()); ps.setBinaryStream(13,new ByteArrayInputStream(baosorganiseNo.toByteArray()),baosorganiseNo.toByteArray().length); System.out.println(provider.getOrganiseNo().getFileSize()); provider.getLicence().destroy(); provider.getTaxLicence().destroy(); provider.getOrganiseNo().destroy(); provider是form对象,你可以参考看看 这个是表单 <tr> <td class=td noWrap colspan="3"> <input class=edline style="WIDTH: 250px; HEIGHT: 22px" type=file name=licence> </td> </tr> <tr> <td class=td noWrap colspan="3"> <input class=edline style="WIDTH: 250px; HEIGHT: 22px" type=file name=taxLicence> </td> </tr> <tr> <td class=td noWrap colspan="3"> <input class=edline style="WIDTH: 250px; HEIGHT: 22px" type=file name=organiseNo> </td> </tr> Struts中有上传得类,支持多个文件上传。到apache网站上下在一个struts的例子研究一下 同意Yansharp(喜之郎)的说法很简单的哦 Struts中有org.apache.struts.upload.FormFile类的,再用getInputStream这个方法就可以了. 至于一个或多个,没什么不一样,只要用FormFile类就行了. 下面是我自己做的小程序,但是我不想用println换行,我想用\n换行,怎样修改我的程序。 HQL查询问题。查询结果是范型List吗? 求助。。。java短信开发程序找不到串口信息 freemarker标签问题.. hql日期比较问题 一个项目:要给大量的用户群发邮件的疑问 请帮我看看webservice调用的问题谢谢! 再问简单问题!JSP方面的。 Struts中ActionForm问题 冒昧问一句,OpenTools和EJB有什么关系,EJB有那么重要吗,我用JBuilder里的大部分控件就可以搞定大部分程序了? 在线急求j2ee的面试问题 500分求助,java文字游戏源码!
ByteArrayOutputStream baostaxLicence = new ByteArrayOutputStream();
ByteArrayOutputStream baosorganiseNo = new ByteArrayOutputStream();
try {
InputStream streamLicence = provider.getLicence().getInputStream();
InputStream streamtaxLicence = provider.getTaxLicence().getInputStream();
InputStream streamorganiseNo = provider.getOrganiseNo().getInputStream();
//taxLicence
byte[] bufferLicence = new byte[8192];
int bytesReadLicence = 0;
while ((bytesReadLicence = streamLicence.read(bufferLicence, 0, 8192)) != -1) {
baosLicence.write(bufferLicence, 0, bytesReadLicence);
}
//taxLicence
byte[] buffertaxLicence = new byte[8192];
int bytesReadtaxLicence = 0;
while ((bytesReadtaxLicence = streamtaxLicence.read(buffertaxLicence, 0, 8192)) != -1) {
baostaxLicence.write(buffertaxLicence, 0, bytesReadtaxLicence);
}
//organiseNo
byte[] bufferorganiseNo = new byte[8192];
int bytesReadorganiseNo = 0;
while ((bytesReadorganiseNo = streamorganiseNo.read(bufferorganiseNo, 0, 8192)) != -1) {
baosorganiseNo.write(bufferorganiseNo, 0, bytesReadorganiseNo);
}
ps.setBinaryStream(11,new ByteArrayInputStream(baosLicence.toByteArray()),baosLicence.toByteArray().length);
System.out.println(provider.getLicence().getFileSize());
ps.setBinaryStream(12,new ByteArrayInputStream(baostaxLicence.toByteArray()),baostaxLicence.toByteArray().length);
System.out.println(provider.getTaxLicence().getFileSize());
ps.setBinaryStream(13,new ByteArrayInputStream(baosorganiseNo.toByteArray()),baosorganiseNo.toByteArray().length);
System.out.println(provider.getOrganiseNo().getFileSize());
provider.getLicence().destroy();
provider.getTaxLicence().destroy();
provider.getOrganiseNo().destroy();
<tr>
<td class=td noWrap colspan="3">
<input class=edline
style="WIDTH: 250px; HEIGHT: 22px" type=file name=licence>
</td>
</tr>
<tr>
<td class=td noWrap colspan="3">
<input class=edline
style="WIDTH: 250px; HEIGHT: 22px" type=file name=taxLicence>
</td>
</tr>
<tr>
<td class=td noWrap colspan="3">
<input class=edline
style="WIDTH: 250px; HEIGHT: 22px" type=file name=organiseNo>
</td>
</tr>
很简单的哦