zoukankan      html  css  js  c++  java
  • 下载文件

    public void downloadFile(HTTPContext context) throws IOException {
            String fileId = context.getParameter("fileId");
            SEntity sFile = new SEntity("VIEW_OA_DEPT_DOCUMENT");
            sFile.addCondition("ID=?", fileId);
            baseDao.load(sFile);
            //查询对应的附件
            String doc_id=sFile.getValueAsString("DOC_ID");
            SEntity entity=new SEntity("sys_upload_file");
            entity.addCondition("ID=?", doc_id);
            baseDao.load(entity);
            context.response.setCharacterEncoding("utf-8");
            context.response.setHeader("Cache-control", "no-cache");
            context.response.setHeader("Content-Disposition", "attachment; filename=" +new String(sFile.getValueAsString("FILENAME").getBytes(),"ISO8859-1")); 
            Blob blob = entity.getValueAsBLOB("CONTENT");
            try {
                InputStream input = blob.getBinaryStream();
                IOUtils.copy(input, context.response.getOutputStream());
                IOUtils.closeQuietly(input);
            } catch (SQLException e) {
                e.printStackTrace();
            } 
        }
  • 相关阅读:
    go,指针
    go ,字符串的编码及如何统计字符长度,
    go中的map,如python中的字典
    go 可变长参数的应用
    go 数组切片
    Django 模板层
    Django的路由层和视图层
    Django
    Django简介
    JQurey
  • 原文地址:https://www.cnblogs.com/clovem/p/6860050.html
Copyright © 2011-2022 走看看