<s:file/>多文件上传
来源:互联网 发布:索尼lt29i网络 编辑:程序博客网 时间:2024/06/02 01:58
<s:file/>有个属性multiple 在标签上添加这属性<s:file name="" id="" multiple/>这样就能同时选中多个文件来选择上传了
upload.jsp
<s:form action="resourceAction_addExercises" name="exerciseForm" id="exerciseForm" method="post" enctype="multipart/form-data">
<input type="file" name="exercise" multiple/>
</s:form>
后台Action
Resource resource[]=new Resource[20];//数组对象
private File[] exercise;//上传文件(与标签名一致)
private String[] exerciseFileName;//上传文件名
private String[] exerciseContentType;//上传文件类型
。。。。。。。。。。。。。分别实现get、set方法
方法体
try{int i;FileInputStream is=null;FileOutputStream fost=null;for(i = 0;i < exercise.length;i++){ is = new FileInputStream(exercise[i]);//String root = ServletActionContext.getServletContext().getRealPath("/upload");//得到当前目录下的upload目录的绝对路径 fost = new FileOutputStream(ServletActionContext.getServletContext() .getRealPath("exercises/" + exerciseFileName[i]));int length = 0;byte[] buffer = new byte[1024];while((length = is.read(buffer))!=-1){fost.write(buffer, 0, length);}ActionContext.getContext().getSession().put("exe", "文件上传成功!");is.close(); fost.close(); } }catch(Exception e){ e.printStackTrace(); return INPUT; } return "toexercise"; }
- <s:file/>多文件上传
- Struts2-文件上传-<s:file>标签使用
- Struts 2 <s:file>标签上传GB级别文件或多文件
- File + C# 多文件上传
- 解决<s:file>上传文件大小和 不能获取文件问题
- Html中file实现多文件上传
- SpringMVC File Upload 多文件上传
- PHP 多input file文件上传
- 多文件上传(input标签file)
- input标签file 多文件上传
- html:file上传文件
- Ext file 上传文件
- input file 上传文件
- input file文件上传
- H5上传文件file
- file文件上传总结
- RAP upload file 上传文件
- 文件上传 file submit button
- Android蓝牙4.0的数据通讯
- AfxGetApp用法
- 吐槽蛋疼的工作
- MyEclipse快捷键大全 _转自 http://www.cnblogs.com/strivers/archive/2011/02/06/1949477.html
- 云计算设计模式(十五)——管道和过滤器模式
- <s:file/>多文件上传
- 计划
- Mac下Eclipse连接不上Android手机的解决方法
- FLASH 、SRAM、SDRAM 的区别
- HTML学习笔记-----简单文本标签举例
- [Phonegap+Sencha Touch] 移动开发17 使用桌面版chrome调试安卓设备上的chrome和webview
- poj 3469 Dual Core CPU (网络流模型)
- xcode6.1调试的时候有时参数都为nil怎么解决?
- 利用百度地图api批量获取地名的详细地址信息