struts2多文件上传
来源:互联网 发布:后期视频制作软件 编辑:程序博客网 时间:2024/05/29 19:15
多文件上传的原理与单文件上传是一样的。
但要注意:
1.jsp中多个input标签内的名字必须一致。
<form action="user/newFileUpMore" method="post" enctype="multipart/form-data"> <input type="file" name="newFileUpMore"/> <input type="file" name="newFileUpMore"/> <input type="file" name="newFileUpMore"/> <input type="submit" value="上传"></form>2.action接收数据要用数组
private File[] newFileUpMore;private String[] newFileUpMoreContentType;private String[] newFileUpMoreFileName;//这里省略它们的get和set方法文件上传<pre name="code" class="html">public String upMoreFile() {String realPath=ServletActionContext.getServletContext().getRealPath("/image");File file=new File(realPath);if(!file.exists()) {file.mkdirs();}try {for(int i=0; i<newFileUpMore.length; i++) {FileUtils.copyFile(newFileUpMore[i], new File(file,newFileUpMoreFileName[i]));}} catch (IOException e) {e.printStackTrace();}return "success";}
0 0
- Struts2多文件上传
- struts2多文件上传
- struts2多文件上传
- struts2 多文件上传
- struts2多文件上传
- struts2多文件上传
- struts2多文件上传
- struts2多文件上传
- Struts2多文件上传
- Struts2多文件上传
- Struts2 多文件上传
- struts2多文件上传
- struts2 多文件上传
- Struts2多文件上传
- struts2多文件上传
- struts2 多文件上传
- struts2多文件上传
- struts2多文件上传
- 腾讯社招笔试题,仅供参考
- 用css3制作一个好看的button
- Win7虚拟Wifi热点(设置后能连接wi…
- 怎么用迅雷下载百度网盘中的大文件…
- 将博客搬至CSDN
- struts2多文件上传
- maven环境配置
- 多点触控介绍以及程序代码
- android使用pull解析器读写xml文件…
- android下使用dom读写xml文件
- 写给爸的
- dos2unix命令
- onPreviewFrame的调用
- EditPlus 快捷键