- 浏览: 943005 次
- 性别:
- 来自: 重庆
文章分类
- 全部博客 (453)
- Windows phone 7 (0)
- Andriod (47)
- iPhone (1)
- Web (30)
- J2EE (34)
- stucts 2学习笔记 (34)
- 开发项目 (3)
- spring学习笔记 (24)
- EJB学习笔记 (6)
- Hibernate学习笔记 (15)
- JPA学习笔记 (8)
- Jsp (11)
- ajax (7)
- 异常收集模块 (1)
- jquery (2)
- phoneGap (2)
- jquery Mobile (0)
- java面试总结 (5)
- Object-C (0)
- javascript (6)
- Eclipse (5)
- 支付集成 (2)
- Weblogic (1)
- Dubbox (5)
- Redis (10)
- linux (21)
- Codis (2)
- React Native (0)
- Mysql (6)
- Docker (3)
- 自动化部署 (1)
- 项目Bug管理平台 (2)
- 负载均衡 (1)
- Mycat (2)
- Java基础知识 (16)
- 数据库 (7)
- Maven (17)
- Kafka (21)
- logs (2)
- 大并发 (2)
- 消息中间件 (2)
- 分布式锁 (3)
- 算法 (4)
- 数字证书原理,公钥私钥 (0)
- 数字证书原理 (1)
- 公钥私钥 (1)
- zookeeper (4)
- Hbase (9)
- Hadoop (2)
- storm (2)
- 通信协议 (1)
- Hive (3)
- git (1)
- JVM (2)
- 大数据相关算法 (1)
- idea (5)
- 将博客搬至CSDN (1)
- 设计模式 (2)
- 表达式 (1)
- 代码审查工具 (0)
- 开源项目 (1)
- PyCharm (0)
- python (6)
- Kubernetes (1)
- swagger (1)
- Maven中mirrors和repository的关系 (0)
- RabbitMQ (3)
- redisson (1)
- k8s (2)
- Mac (1)
最新评论
-
misisipi101:
假设库已经分为32个,那么要扩展到64个,怎样做呢
订单分库分表实践总结以及关键步骤 -
mfkxk298:
简单明了的例子,解决了问题,谢谢啦!
关于ListView中notifyDataSetChanged()刷新数据不更新原因 -
whbwang:
" target="_blank" ...
java web开发 高并发处理 -
suguoqian:
...
java web开发 高并发处理 -
xiangnanyujing:
Dubbox+Redis3.0+Spring+Hibernate+zookeeper实现消息推送核心搭建
在stucts中多文件上传的实现:
第一步:在WEB-INF/lib下加入commons-fileupload-1.2.1.jar、commons-io-1.3.2.jar。这两个文件可以从http://commons.apache.org/下载。
第二步:编写一个提交的表单mulpfileupload.jsp
注意:其中多文件上传时name必须相同应为在接收的时候时以数组的形式接收滴
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<form enctype="multipart/form-data" action="${pageContext.request.contextPath}/test/mulpupload.action" method="post">
<input type="file" name="uploadImages"><br/>
<input type="file" name="uploadImages"><br/>
<input type="file" name="uploadImages"><br/>
<input type="submit" value="提交"><br/>
</form>
<body>
</body>
</html>
第二步:编写Action
public class MulpUploadeFile {
//uploadImages这个和提交上name必须相同、多个文件上传
private File[] uploadImages;
//-ContentType文件类型
private String uploadImagesContentType;
///-FileName文件名、这里是数组因为上传了多个文件
private String[] uploadImagesFileName;
private String path;
public String getPath() {
return path;
}
public File[] getUploadImages() {
return uploadImages;
}
public void setUploadImages(File[] uploadImages) {
this.uploadImages = uploadImages;
}
public String getUploadImagesContentType() {
return uploadImagesContentType;
}
public void setUploadImagesContentType(String uploadImagesContentType) {
this.uploadImagesContentType = uploadImagesContentType;
}
public String[] getUploadImagesFileName() {
return uploadImagesFileName;
}
public void setUploadImagesFileName(String[] uploadImagesFileName) {
this.uploadImagesFileName = uploadImagesFileName;
}
public String upload()throws Exception
{
String realpath = ServletActionContext.getServletContext().getRealPath("/images");
File file = new File(realpath);
if(!file.exists()) file.mkdirs();
path=file.getAbsolutePath();
for(int i=0 ;i<uploadImages.length; i++){
File uploadImage = uploadImages[i];
FileUtils.copyFile(uploadImage,new File(file,uploadImagesFileName[i]));
}
return "success";
}
//文件所在路径F:\myeclipse\.metadata\.plugins\com.genuitec.eclipse.easie.tomcat.myeclipse\tomcat\webapps\Structs2\images
}
第三步:配置stucts.xml文件
<action name="mulpupload" class="com.liyong.MulpUploadeFile.MulpUploadeFile" method="upload" >
<result name="success">/WEB-INF/page/success.jsp</result>
<!-- 访问路径 http://localhost:8080/Structs2/test/sevletScope -->
</action>
第四步:部署
第五步:访问//http://localhost:8080/Structs2/mulpfileupload.jsp
.....
第一步:在WEB-INF/lib下加入commons-fileupload-1.2.1.jar、commons-io-1.3.2.jar。这两个文件可以从http://commons.apache.org/下载。
第二步:编写一个提交的表单mulpfileupload.jsp
注意:其中多文件上传时name必须相同应为在接收的时候时以数组的形式接收滴
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<form enctype="multipart/form-data" action="${pageContext.request.contextPath}/test/mulpupload.action" method="post">
<input type="file" name="uploadImages"><br/>
<input type="file" name="uploadImages"><br/>
<input type="file" name="uploadImages"><br/>
<input type="submit" value="提交"><br/>
</form>
<body>
</body>
</html>
第二步:编写Action
public class MulpUploadeFile {
//uploadImages这个和提交上name必须相同、多个文件上传
private File[] uploadImages;
//-ContentType文件类型
private String uploadImagesContentType;
///-FileName文件名、这里是数组因为上传了多个文件
private String[] uploadImagesFileName;
private String path;
public String getPath() {
return path;
}
public File[] getUploadImages() {
return uploadImages;
}
public void setUploadImages(File[] uploadImages) {
this.uploadImages = uploadImages;
}
public String getUploadImagesContentType() {
return uploadImagesContentType;
}
public void setUploadImagesContentType(String uploadImagesContentType) {
this.uploadImagesContentType = uploadImagesContentType;
}
public String[] getUploadImagesFileName() {
return uploadImagesFileName;
}
public void setUploadImagesFileName(String[] uploadImagesFileName) {
this.uploadImagesFileName = uploadImagesFileName;
}
public String upload()throws Exception
{
String realpath = ServletActionContext.getServletContext().getRealPath("/images");
File file = new File(realpath);
if(!file.exists()) file.mkdirs();
path=file.getAbsolutePath();
for(int i=0 ;i<uploadImages.length; i++){
File uploadImage = uploadImages[i];
FileUtils.copyFile(uploadImage,new File(file,uploadImagesFileName[i]));
}
return "success";
}
//文件所在路径F:\myeclipse\.metadata\.plugins\com.genuitec.eclipse.easie.tomcat.myeclipse\tomcat\webapps\Structs2\images
}
第三步:配置stucts.xml文件
<action name="mulpupload" class="com.liyong.MulpUploadeFile.MulpUploadeFile" method="upload" >
<result name="success">/WEB-INF/page/success.jsp</result>
<!-- 访问路径 http://localhost:8080/Structs2/test/sevletScope -->
</action>
第四步:部署
第五步:访问//http://localhost:8080/Structs2/mulpfileupload.jsp
.....
发表评论
-
struts2的原理
2016-07-04 09:56 576众所周知,Struts2是个 ... -
重庆APP开发 重庆Android 重庆Ios 爬虫科技 重庆爬虫科技
2014-10-06 12:03 9<!--[if gte mso 9]><x ... -
国际化-配置全局资源与输出国际化信息及带占位符
2012-05-08 12:06 5285知识点: 【 <1、国际化: 准备资源文件,资源文件的 ... -
国际化-配置全局资源与输出国际化信息及带占位符
2012-05-04 15:38 0知识点: 【 <1、国际化: 准备资源文件,资源文件的 ... -
基于XML校验的一些特点
2012-05-08 12:05 963【 当为某个action提供了ActionClassName ... -
基于XML配置方式对指定action方法实现输入校验
2012-05-07 08:17 1208知识点: 【 当校验文件的取名为ActionClassNam ... -
基于XML配置方式实现对action的所有方法进行输入校验
2012-05-07 08:17 1358】 知识点: 】 使用基于XML配置方式实现输入校验时,Act ... -
输入校验的流程
2012-05-07 08:17 10991。类型转换器对请求参数执行类型转换,并把转换后的值赋给act ... -
手工编写代码实现对action指定方法输入校验
2012-05-07 08:17 1329知识点: 通过validateXxx()方法实现, vali ... -
手工编写代码实现对action中所有方法输入校验
2012-05-07 08:17 1158知识点: 通过重写validate() 方法实现, vali ... -
自定义拦截器
2012-05-03 13:40 0先看看下面的资料: <package name=&qu ... -
自定义拦截器
2012-05-03 13:39 0先看看下面的资料: <package name=&qu ... -
自定义拦截器
2012-05-03 13:39 0先看看下面的资料: <package name=&qu ... -
自定义拦截器
2012-05-03 13:39 0先看看下面的资料: <package name=&qu ... -
自定义拦截器
2012-05-03 13:39 0先看看下面的资料: <package name=&qu ... -
自定义拦截器
2012-05-03 13:39 0先看看下面的资料: <package name=&qu ... -
自定义拦截器
2012-05-03 13:39 0先看看下面的资料: <package name=&qu ... -
自定义拦截器
2012-05-06 10:41 1103先看看下面的资料: <package name=&qu ... -
自定义拦截器
2012-05-03 13:39 0先看看下面的资料: <package name=&qu ... -
自定义拦截器
2012-05-03 13:39 0先看看下面的资料: <package name=&qu ...
相关推荐
在Java开发中,多文件上传是一项常见的功能,尤其在Web应用中,用户可能需要一次性上传多个文件,如图片、文档等。本知识点将详细介绍如何在Java中实现这一功能,以及结合Flash实现上传界面并显示上传进度条。 1. *...
多文件上传功能则意味着用户可以一次性选择并上传多个文件,大大提高了数据传输的效率。 【详细实现】 1. **引入资源**:首先,你需要在HTML文件中引入Bootstrap和Bootstrap-fileinput的相关CSS和JS文件。这些文件...
在EXTJS中,`MultiFileUploadField` 是一个组件,它允许用户在单个操作中选择并上传多个文件,极大地提升了用户交互体验。这个功能对于处理大量文件上传的场景非常有用,比如在内容管理系统、图像库或者文件分享平台...
这个源码可能提供了一种实现方式,允许用户同时上传多个文件,并且带有进度条显示,用户可以随时停止或删除正在上传的文件。这样的功能提高了用户体验,因为它允许用户批量处理文件,而无需逐一操作。 在实现多文件...
基于SpringBoot的文件上传系统,前后端分离,单文件上传,多文件上传,大文件上传,断点续传,文件秒传,图片上传 项目经过严格测试,确保可以运行! 采用前后端分离的方式进行开发,实现了几种常用的文件上传功能...
"JSP多文件上传"是一个常见的需求,特别是在文件分享、在线教育或文档管理等场景。这个功能允许用户一次性选择并上传多个文件,提高了用户体验,减少了多次点击和等待时间。 实现JSP多文件上传,我们需要了解以下几...
在多文件上传的场景中,JSP主要负责接收和处理来自客户端的文件上传请求。 在"MultifileUploadDemo"中,我们利用了Flash作为前端的上传组件。Flash因其支持多媒体和交互性而被广泛用于创建丰富的互联网应用程序。在...
对于初学者来说,理解并实现多文件上传是一项重要的技能,它可以帮助你构建交互性强、功能完善的Web应用程序。在这个"C# .NET FileUpload 多文件上传例子"中,我们将探讨两种主要的方法,帮助你理解和掌握这一关键...
在本项目中,"javascript+HTML5 多文件上传(插件)多进度条显示"是一个实现这一功能的实例,它允许用户选择并上传多个文件,并在上传过程中实时显示每个文件及整体的上传进度。下面将详细介绍这个技术实现的关键...
标题中的“Flash实现的多文件上传”指的是使用Adobe Flash技术来实现用户在Web页面上同时上传多个文件的功能。Flash在过去的网页开发中被广泛应用于多媒体交互和富互联网应用(RIA),其中包括文件上传功能,因为它...
这个功能通常在网页应用中用于让用户能够一次性上传多个文件,如图片、文档等,极大地提高了用户体验。 多文件上传通常涉及以下几个关键技术点: 1. **HTML5 File API**: 这是实现多文件上传的基础。File API允许...
多文件上传是指一次操作中上传多个文件的能力。这种功能常见于照片分享网站、文档管理应用等。实现多文件上传,通常有以下方法: 1. **HTML5 File API**:现代浏览器支持HTML5的File API,可以一次性选择并上传多个...
在IT行业中,多文件上传是一项常见的功能,尤其在网页应用和桌面软件中,它允许用户一次选择并上传多个文件,极大地提高了工作效率。本资源提供的是一款基于Eclipse开发的多文件上传组件,它可以帮助开发者轻松地...
在IT行业中,文件上传是网页应用中常见的功能之一,尤其在大数据时代,用户可能需要一次上传多个文件。"uploadify"是一款广泛使用的JavaScript插件,它使得多文件上传变得简单而高效。本示例代码是关于如何使用...
这里,我们主要关注"springMVC多文件上传需要的jar"这一资源,它包含了实现这一功能所必需的Java档案(JAR)文件。 首先,Spring MVC是Spring框架的一个模块,专门处理Web应用的请求和响应。它提供了模型-视图-控制...
在Java开发中,多文件上传是一项常见的功能,尤其在Web应用程序中,如用户需要上传图片、文档等附件。本示例提供了实现这一功能的具体代码和数据库相关资源,旨在帮助开发者快速构建自己的多文件上传功能。 首先,...
1. **多文件上传**:多文件上传是指用户可以在一次操作中选择并上传多个文件,而不是逐个上传。这提高了用户体验,减少了用户的交互次数。在HTML5中,`<input type="file" multiple>`标签被引入,使得浏览器支持多选...
在Web应用中,多文件上传功能通常用于让用户一次性上传多个文件,比如图片、文档等。ExtJS4提供了一种解决方案,允许用户通过一个交互式的界面来上传多个文件,并可以分别处理每个文件的上传状态。 **三、上传组件...
在现代Web应用中,用户可能需要一次性上传多个文件,例如图片、文档或视频。这个过程如果能实时显示每个文件的上传进度,将极大地提升用户体验。本文将深入探讨如何实现"多文件上传,并显示每一个的进度"这一功能,...