在struts1.1框架下,利用smartupload实现文件的上传(可以是多个文件)
来源:互联网 发布:淘宝店铺手机版模板 编辑:程序博客网 时间:2024/06/05 09:26
1、前端页面upload.jsp,后台处理程序UplodAction.java
2、struts.config的配置参数如下(没有设置ActionForm):
<action input="/upload.jsp" path="/save" scope="request" type="yhp.test.web.UploadAction" validate="false">
<forward name="success" path="/list.do" />
</action>
3、upload.jsp页面中主要部分代码
<%@ page contentType="text/html; charset=GBK"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html:html>
<head>
<title> 测试Struts利用SmartUpload上传文件 </title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
</head>
<body>
<html:form action="/save.do" styleId="formItem" method="post" enctype="multipart/form-data">
<html:hidden property="id"/>
<html:file property="serverpath" styleClass="input-text"></html:file>
</html:form>
</body>
</html:html>
4、UploadAction.java
import com.jspsmart.upload.File;
import com.jspsmart.upload.Files;
import com.jspsmart.upload.SmartUpload;
public ActionForward doBatchsave(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws Exception {
SmartUpload mySmartUpload = new SmartUpload();
mySmartUpload.initialize(getServlet().getServletConfig(),httpServletRequest, httpServletResponse);
mySmartUpload.upload();
//获取除文件以外的相关信息,例如upload.jsp中隐藏控件id的值
String strId=(String)mySmartUpload.getRequest().getParameter("id");
Files files=mySmartUpload.getFiles();
Collection col=files.getCollection();
Iterator it=col.iterator();
while(it.hasNext()){
File file=(File)it.next();
String oldFileName=file.getFileName();
String extname=file.getFileExt();
String fileName=Sequence.getSequence()+"."+extname;//产生一个唯一的文件名
file.saveAs("c://temp/"+fileName);
}
return (actionMapping.findForward("success"));
}
2、struts.config的配置参数如下(没有设置ActionForm):
<action input="/upload.jsp" path="/save" scope="request" type="yhp.test.web.UploadAction" validate="false">
<forward name="success" path="/list.do" />
</action>
3、upload.jsp页面中主要部分代码
<%@ page contentType="text/html; charset=GBK"%>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-html" prefix="html" %>
<%@ taglib uri="http://java.sun.com/jstl/core" prefix="c" %>
<html:html>
<head>
<title> 测试Struts利用SmartUpload上传文件 </title>
<meta http-equiv="Content-Type" content="text/html; charset=GBK">
</head>
<body>
<html:form action="/save.do" styleId="formItem" method="post" enctype="multipart/form-data">
<html:hidden property="id"/>
<html:file property="serverpath" styleClass="input-text"></html:file>
</html:form>
</body>
</html:html>
4、UploadAction.java
import com.jspsmart.upload.File;
import com.jspsmart.upload.Files;
import com.jspsmart.upload.SmartUpload;
public ActionForward doBatchsave(ActionMapping actionMapping,
ActionForm actionForm, HttpServletRequest httpServletRequest,
HttpServletResponse httpServletResponse) throws Exception {
SmartUpload mySmartUpload = new SmartUpload();
mySmartUpload.initialize(getServlet().getServletConfig(),httpServletRequest, httpServletResponse);
mySmartUpload.upload();
//获取除文件以外的相关信息,例如upload.jsp中隐藏控件id的值
String strId=(String)mySmartUpload.getRequest().getParameter("id");
Files files=mySmartUpload.getFiles();
Collection col=files.getCollection();
Iterator it=col.iterator();
while(it.hasNext()){
File file=(File)it.next();
String oldFileName=file.getFileName();
String extname=file.getFileExt();
String fileName=Sequence.getSequence()+"."+extname;//产生一个唯一的文件名
file.saveAs("c://temp/"+fileName);
}
return (actionMapping.findForward("success"));
}
- 在struts1.1框架下,利用smartupload实现文件的上传(可以是多个文件)
- SmartUpload 文件的上传
- smartupload实现文件的上传、下载
- Smartupload 实现文件的上传与下载
- 利用struts1 formfile实现文件上传功能
- SmartUpload组件实现文件上传
- 用SmartUpload实现文件上传
- 利用Struts1实现多个文件的上传
- 利用struts1进行多文件的上传
- smartupload处理文件的上传
- SmartUpload上传组件实现文件的上传和下载功能
- struts1.2下实现文件上传进度条
- struts1 实现 文件上传
- Struts1实现文件上传
- 使用Struts1实现文件上传(二) 连接使用Struts1实现文件上传(1)
- 在struts框架下实现文件的上传
- 文件上传--基于Spring MVC框架+SmartUpload
- 关于SmartUpload在WebLogic集群下上传文件的共享方案
- 北极光合伙人邓锋:要别人跳火坑,你自己先跳
- 如何利用java得到当前的时间和前一天的时间
- About virtual destruction
- 在struts框架下实现文件的上传
- Gtk+ 基础
- 在struts1.1框架下,利用smartupload实现文件的上传(可以是多个文件)
- [数据库]MYSQL数据库常用命令集合
- moon.png
- 简单工厂模式
- Google 浏览器的简单使用
- uClinux 在EasyARM2200开发板上的运行
- Web.py .3中的get中文参数问题
- 老外眼里的中式英语
- 手机黑盒测试方式与方法