Struts Updownload 源码

时间:2016-04-17 08:11:17
【文件属性】:

文件名称:Struts Updownload 源码

文件大小:4.76MB

文件格式:ZIP

更新时间:2016-04-17 08:11:17

Struts Updownload 源码

Struts Updownload 源码 给出其中一个Action 包中含有整个框架的源码 package com.icss.action; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; import java.io.UnsupportedEncodingException; import org.apache.struts2.ServletActionContext; import com.opensymphony.xwork2.ActionSupport; public class DownloadAction extends ActionSupport { /** * */ private static final long serialVersionUID = 1L; private String path; private String fileName; private String contentDisposition; public InputStream getInputStream()throws Exception{ /* * 从ServletContext容器根目录拿去相关资源文件,它被result(type="stream")stream指定类调用,因此在 * result中要指定关联关系inputStream * */ System.out.println("download action is invoked!!"); String realPath=ServletActionContext.getServletContext().getRealPath("/"+this.getPath()+"/"+fileName); System.out.println(realPath); return ServletActionContext.getServletContext().getResourceAsStream(this.getPath()+"/"+fileName); } @Override public String execute() throws Exception { return SUCCESS; } public String getPath() { return path; } public void setPath(String path) throws UnsupportedEncodingException { this.path = new String(path.getBytes("ISO-8859-1"),"UTF-8"); } public String getFileName() { return fileName; } public void setFileName(String fileName) throws UnsupportedEncodingException { this.fileName = new String(fileName.getBytes("ISO-8859-1"),"UTF-8"); } public String getContentDisposition() { return contentDisposition; } public void setContentDisposition(String contentDisposition) { this.contentDisposition = fileName; } }


【文件预览】:
struts_updownload
----WebContent()
--------META-INF()
--------WEB-INF()
--------result.jsp(1KB)
--------js()
--------index.jsp(964B)
----.settings()
--------org.eclipse.wst.jsdt.ui.superType.name(6B)
--------org.eclipse.wst.common.project.facet.core.xml(349B)
--------org.eclipse.wst.common.component(481B)
--------org.eclipse.wst.jsdt.ui.superType.container(49B)
--------.jsdtscope(503B)
--------org.eclipse.jdt.core.prefs(395B)
----说明.txt(132B)
----src()
--------com()
--------struts.xml(865B)
----.project(1KB)
----.classpath(845B)
----数据库.txt(149B)
----build()
--------classes()

网友评论

  • 有错误,不能运行