OAF doesn't readily expose the Controller Servlet's HttpRequest and HttpResponse objects so you need to extract it from the OAPageContext object via:

HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletResponse();

Once you get the response object you could already manipulate its OutputStream.

public void downloadFile(OAPageContext pageContext) {

         HttpServletResponse response = (HttpServletResponse) pageContext.getRenderingContext().getServletResponse();

         File fileToDownload = this.createFile();

         String fileType = getMimeType("txt");
response.setContentType(fileType);
response.setContentLength((int) fileToDownload.length());
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileToDownload.getName() + "\""); InputStream in = null;
ServletOutputStream outs = null; try { outs = response.getOutputStream();
in = new BufferedInputStream(new FileInputStream(fileToDownload));
int ch; while ((ch = in.read()) != -1) {
outs.write(ch);
} } catch (IOException e) { // TODO
e.printStackTrace(); } finally { try { outs.flush();
outs.close(); if (in != null) {
in.close();
} } catch (Exception e) { e.printStackTrace(); } } }

参考资料:

Integrate XML Publisher and OA Framework

Downloading Files in OAF (需翻墙)

XMLIntegrationCO

最新文章

  1. 网站为什么要做SEO
  2. linux grep 查找字符串
  3. mysql中的字符串类型数据索引优化
  4. LSB最低有效位隐写入门
  5. jfinal框架教程-学习笔记(二)
  6. VMware Workstation pro 12下载以及序列号
  7. sql server 2005中使用with实现递归
  8. 关于jdbc Oracle数据库连接的URL错误
  9. 《第一行代码》学习笔记14-UI(3)
  10. ActiveMQ的运用
  11. react-native自定义TextInput光标颜色
  12. Docker容器中安装vim
  13. 我发起了一个 ILBC 的 子项目 ILBC Studio
  14. BeanFactory和FactoryBean的区别
  15. 基于spring boot 2.x的websocket示例
  16. 获取当前页面url
  17. WinForm(WPF) splash screen demo with C#
  18. Oracle 12c 用户创建、角色、权限
  19. spring-security(2)
  20. 【转】WireShark 过滤规则

热门文章

  1. python之路----继承的抽象类和接口类
  2. Js中String转int
  3. 基于qml创建最简单的图像处理程序(2)-使用c++&qml进行图像处理
  4. 20145101《Java程序设计》第8周学习总结
  5. C++11标准 STL正则表达式 验证电子邮件地址
  6. IDEA Java开发常用插件
  7. flash,sram
  8. Linux必备知识
  9. mongodb 有一个坑 报错 no mongos proxies found in seed list
  10. Bi-shoe and Phi-shoe(欧拉函数/素筛)题解