5309353bbed6a7600c1e9951e1cca452f6c35148.svn-base 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. <%@page import="com.persistence.DBdll.SysOperator"%>
  2. <%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
  3. <%@ page
  4. import = "com.sysmodel.datamodel.xmlmodel.ModelFactory"
  5. import = "com.sysmodel.datamodel.xmlmodel.able.SysModel"
  6. import = "com.persistence.service.SysPersistence"
  7. import = "com.persistence.service.PersistenceFactory"
  8. import = "javax.servlet.ServletOutputStream"
  9. import = "java.io.PrintWriter"
  10. import = "java.util.ArrayList"
  11. import = "com.sinosoft.common.upLoad.util.*"
  12. import = "com.sinosoft.common.upLoad.service.UploadManageable"
  13. import = "com.sinosoft.common.upLoad.service.UploadManageImpl"
  14. import = "java.net.URLDecoder"
  15. %>
  16. <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
  17. <%@page import="java.io.OutputStream"%>
  18. <%@page import="java.net.URLDecoder"%><html>
  19. <head>
  20. <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
  21. <meta http-equiv="Content-Language" content="UTF-8" />
  22. </head>
  23. <body>
  24. <%
  25. response.setCharacterEncoding("UTF-8");
  26. String objectID = request.getParameter("objectID") == null ? "" : request.getParameter("objectID");
  27. //String classId = request.getParameter("classid") == null ? "" : request.getParameter("classid");
  28. String filename = request.getParameter("filename") == null ? "" : request.getParameter("filename");
  29. String downfilename = request.getParameter("downfilename") == null ? "" : request.getParameter("downfilename");
  30. //autopath=false 自己传入完整路径文件
  31. String autopath = request.getParameter("autopath") == null ? "" : request.getParameter("autopath");
  32. System.out.println(autopath+"====");
  33. if(filename.contains("/")){
  34. return;
  35. }
  36. //optmethod 文件处理方式
  37. //open 打开文件
  38. String optmethod = request.getParameter("optmethod") == null ? "" : request.getParameter("optmethod");
  39. filename = URLDecoder.decode(filename, "UTF-8");
  40. downfilename = URLDecoder.decode(downfilename, "UTF-8");
  41. String uploadType = request.getParameter("uploadType") == null ? "path" : "blob";
  42. //filename = new String(filename.getBytes("iso-8859-1"),"utf-8");
  43. response.reset();
  44. try {
  45. OutputStream sout = response.getOutputStream();
  46. //判断下载方式
  47. System.out.println(autopath);
  48. if (uploadType.equalsIgnoreCase("path")) {
  49. UploadManageable upload = new UploadManageImpl();
  50. if("false".equalsIgnoreCase(autopath.trim())){
  51. upload.downloadFile(request, response, filename, false, downfilename);
  52. }else{
  53. upload.downloadFile(request, response, filename, true, downfilename);
  54. }
  55. }else if (uploadType.equalsIgnoreCase("blob")){
  56. SysModel sysmodel = ModelFactory.getSysmodel();
  57. SysPersistence persistence = PersistenceFactory.getInstance(sysmodel);
  58. persistence.readBlobToOutputStream(110,objectID,"FileContents",sout);
  59. }
  60. out.clear();
  61. out = pageContext.pushBody();
  62. }catch (Exception e) {
  63. e.printStackTrace();
  64. }
  65. %>
  66. </body>
  67. </html>