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(); } }