如何实现下载文件之二:动态文件
来源:互联网 发布:网络众筹 编辑:程序博客网 时间:2024/04/29 03:04
实验环境:JDeveloper 11.1.2.0.0。
说明:本文改自本人旧作,使用了目前最新的JDeveloper 11.1.2.0.0重新开发验证。(2011-8-3)
文件的内容是动态生成的。
1. 页面代码
这里使用了af:fileDownloadActionListener 组件。
<af:form id="f1">
<af:commandButton text="Download" id="cb1">
<af:fileDownloadActionListener filename="hello.txt" contentType="text/plain; charset=utf-8"
method="#{myBackingBean.writeContent}"/>
</af:commandButton>
</af:form>
2. 对应的Managed Bean代码
public void writeContent(FacesContext facesContext, OutputStream out) {
try {
OutputStreamWriter w = new OutputStreamWriter(out, "UTF-8");
w.write("Even a brick wants to be something.");
w.close();
facesContext.responseComplete();
} catch (Exception e) {
e.printStackTrace();
}
}
说明:本文改自本人旧作,使用了目前最新的JDeveloper 11.1.2.0.0重新开发验证。(2011-8-3)
文件的内容是动态生成的。
1. 页面代码
这里使用了af:fileDownloadActionListener 组件。
<af:form id="f1">
<af:commandButton text="Download" id="cb1">
<af:fileDownloadActionListener filename="hello.txt" contentType="text/plain; charset=utf-8"
method="#{myBackingBean.writeContent}"/>
</af:commandButton>
</af:form>
2. 对应的Managed Bean代码
public void writeContent(FacesContext facesContext, OutputStream out) {
try {
OutputStreamWriter w = new OutputStreamWriter(out, "UTF-8");
w.write("Even a brick wants to be something.");
w.close();
facesContext.responseComplete();
} catch (Exception e) {
e.printStackTrace();
}
}
Project下载:DownloadFile.7z。
http://maping930883.blogspot.com/2010/04/adf094.html
0 0
- 如何实现下载文件之二:动态文件
- 如何实现文件下载
- 如何实现下载文件
- 实现动态文件内容下载
- Servlet实现动态文件下载
- WEB项目中如何实现禁止下载文件(二)
- 如何实现多线程下载文件
- php如何实现文件下载
- java如何实现文件下载
- 如何实现下载文件之一:静态文件
- 如何实现文件的断点续传,文件下载
- 使用Servlet实现动态文件下载
- Retrofit实现文件上传和下载【二】
- Java Web实现文件下载(二)
- Struts2文件的上传、下载之二
- 心得6--Response介绍和如何实现动态文件内容的下载详细介绍
- 使用springMVC实现文件上传和下载之文件下载
- response实现案例之实现文件下载
- 1408201941-hd-Elevator.cpp
- 上传文件到服务器方式之二:使用Button的ActionListener
- 如何实现下载文件之一:静态文件
- JsonUtil工具类
- vim中ctrl+z,jobs,fg命令用法
- 如何实现下载文件之二:动态文件
- C 与 C++ 的混合编程
- 在JAVA中使用DES算法
- 高版本Chrome扩展程序强制停止问题
- Spark
- mvn部署的时候如何把配置文件部署进去
- 如何处理BLOB类型数据之一:上传文件并保存到BLOB中
- FatMouse's Speed
- Radar Installation