SWFUpload+struts2 进度条

loverqiao

贡献于2013-08-20

字数:3482 关键词: 文件上传

SWFUpload+struts2 进度条 博客分类: jQuery javascript JavaScriptJSPCSSFlashOS 本案例非本人的原创,是我把多个案例结合,修改其中的错误,补充其中的不足后的代码。 jsp 代码: <%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%> <% String path = request.getContextPath(); String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
文件上传

---------------------------------- java代码: package com.action; import java.io.File; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.InputStream; import java.io.OutputStream; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionSupport; public class FileUploadAction extends ActionSupport { private File file; private String fileFileName; private String fileContentType; public String execute() throws Exception { // 实现上传 InputStream is = new FileInputStream(file); String root = ServletActionContext.getRequest().getRealPath("/upload"); File deskFile = new File(root, this.getFileFileName()); OutputStream os = new FileOutputStream(deskFile); byte[] bytefer = new byte[1024]; int length = 0; while ((length = is.read(bytefer)) != -1) { os.write(bytefer, 0, length); } os.close(); is.close(); return "success"; } public File getFile() { return file; } public void setFile(File file) { this.file = file; } public String getFileFileName() { return fileFileName; } public void setFileFileName(String fileFileName) { this.fileFileName = fileFileName; } public String getFileContentType() { return fileContentType; } public void setFileContentType(String fileContentType) { this.fileContentType = fileContentType; } } SWFUpload_struts2.rar(6.7 MB) 下载次数: 1312

下载文档,方便阅读与编辑

文档的实际排版效果,会与网站的显示效果略有不同!!

需要 2 金币 [ 分享文档获得金币 ]
0 人已下载

下载文档

相关文档