jsp实现文件下载
2012-03-29 17:11
162 查看
jsmartuplod 架包的下载
<%
out.clear();
out = pageContext.pushBody();
SmartUpload su = new SmartUpload();
su.initialize(pageContext);//初始化
//su.setDenyPhysicalPath(true);
//设定contentDisposition为null以禁止浏览器自动打开文件, //保证点击链接后是下载文件。若不设定,则下载的文件扩展名为
//doc时,浏览器将自动用word打开它。扩展名为pdf时, //浏览器将用acrobat打开。
su.setContentDisposition(null); // 下载文件 String
String file = request.getParameter("download");
file=new String(file.getBytes("ISO-8859-1"),"GBK");
su.downloadFile("/upload/attachment/"+file);
response.getOutputStream().close();
out.close();
%
二:
-<result name="success" type="stream"> <param name="inputPath">/upload/attachment/</param>
<!--<param name="contentType">text/plain</param>-->
<param name="inputName">downloadFile</param> <param name="contentDisposition"> attachment;filename="${download}" </param> <param name="bufferSize">4096</param> </result>
private InputStream downloadFile;
public void setDownloadFile(InputStream downloadFile) {
this.downloadFile = downloadFile;
}
public InputStream getDownloadFile() {
return ServletActionContext.getServletContext().getResourceAsStream(
"upload/atachment/SecureCRT 常用命令 .txt");
}
public String getDownload() {
try {
download = new String(download.getBytes("iso-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return download;
}
public void setDownload(String download) {
this.download = download;
}
public String getInputPath() {
return inputPath;
}
public void setInputPath(String inputPath) {
this.inputPath = inputPath;
}
private String inputPath;
public String execute() {
return SUCCESS;
}
<%
out.clear();
out = pageContext.pushBody();
SmartUpload su = new SmartUpload();
su.initialize(pageContext);//初始化
//su.setDenyPhysicalPath(true);
//设定contentDisposition为null以禁止浏览器自动打开文件, //保证点击链接后是下载文件。若不设定,则下载的文件扩展名为
//doc时,浏览器将自动用word打开它。扩展名为pdf时, //浏览器将用acrobat打开。
su.setContentDisposition(null); // 下载文件 String
String file = request.getParameter("download");
file=new String(file.getBytes("ISO-8859-1"),"GBK");
su.downloadFile("/upload/attachment/"+file);
response.getOutputStream().close();
out.close();
%
二:
-<result name="success" type="stream"> <param name="inputPath">/upload/attachment/</param>
<!--<param name="contentType">text/plain</param>-->
<param name="inputName">downloadFile</param> <param name="contentDisposition"> attachment;filename="${download}" </param> <param name="bufferSize">4096</param> </result>
private InputStream downloadFile;
public void setDownloadFile(InputStream downloadFile) {
this.downloadFile = downloadFile;
}
public InputStream getDownloadFile() {
return ServletActionContext.getServletContext().getResourceAsStream(
"upload/atachment/SecureCRT 常用命令 .txt");
}
public String getDownload() {
try {
download = new String(download.getBytes("iso-8859-1"), "UTF-8");
} catch (UnsupportedEncodingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return download;
}
public void setDownload(String download) {
this.download = download;
}
public String getInputPath() {
return inputPath;
}
public void setInputPath(String inputPath) {
this.inputPath = inputPath;
}
private String inputPath;
public String execute() {
return SUCCESS;
}
相关文章推荐
- jspsmart实现文件上传下载
- 使用jsp/servlet简单实现文件上传与下载
- 项目开发技巧(四):使用JspSmartupload实现文件上传下载(二):jspSmartUpload上传下载全攻略(ZZ)
- jspsmart实现文件的上传与下载
- jsp中文件下载的实现
- 如何使 FlashGet "正常合法" 下载 Session 中的自定义文件链接呢? JSP/Servlet 实现!
- jspsmart实现页面不跳转上传和下载文件(二)
- 用Jsp来实现文件下载功能的几种方式(2)
- java+jsp代码实现从FTP服务器上传下载文件
- 【ZT】Jsp/Servlet:实现文件上传与下载【二】
- jsp实现文件下载的方法
- jsp实现文件下载的代码(通过文件流方式)
- JSP用common-fileupload实现文件上传下载
- jsp简单实现提供文件下载
- jsp下载文件的实现方法及注意事项 (转)
- 项目开发技巧(四):使用JspSmartupload实现文件上传下载(三):jspsmartupload samples
- jsp实现文件下载与中文文件名乱码问题解决
- 如何使 FlashGet "正常合法" 下载 Session 中的自定义文件链接呢? JSP/Servlet 实现!
- Jsp/Servlet:实现文件上传与下载
- JSP实现文件下载