//导出下载方法 long time = System.currentTimeMillis(); String realpath1 = this.getClass().getClassLoader().getResource("").getPath();// classes 目录的物理路径 String parent = new File(realpath1).getParent();// WEB-INF 目录的物理路径 String parent2 = new File(parent).getParent()+"/upload/files/"+time+"xbl.pdf";// WebRoot 目录的物理路径 String fileUrl = "./upload/files/"+time+"xbl.pdf"; //生成附件 File file = new File(parent2); file.createNewFile(); //附件 存入附件表 TSAttachment tsAttachment = new TSAttachment(); if (org.jeecgframework.core.util.StringUtil.isNotEmpty(time+"xbl")) { tsAttachment.setNote(time+"xbl"); } tsAttachment.setExtend("pdf"); tsAttachment.setSubclassname(MyClassLoader.getPackPath(tsAttachment)); tsAttachment.setCreatedate(DateUtils.gettimestamp()); tsAttachment.setAttachmenttitle(time+"_print"); tsAttachment.setRealpath(fileUrl); systemService.save(tsAttachment); TSDocument document = new TSDocument(); document.setId(tsAttachment.getId()); systemService.save(document); TSTypegroup tsTypegroup=systemService.getTypeGroup("fieltype","文档分类"); TSType tsType = systemService.getType("files","附件", tsTypegroup); //设置其可在线预览 ReflectHelper reflectHelper = new ReflectHelper(tsAttachment); reflectHelper.setMethodValue("swfpath", "upload/files/" + FileUtils.getFilePrefix(time+"xbl.pdf") + ".swf"); SwfToolsUtil.convert2SWF(parent2); FileOutputStream out = new FileOutputStream(file); out.write(byteStream.toByteArray()); out.close(); //用jeecg框架的方法下载刚刚生成的附件 UploadFile uploadFile = new UploadFile(request, response); String contentfield = oConvertUtils.getString(request.getParameter("contentfield"), uploadFile.getByteField()); byte[] content = (byte[]) reflectHelper.getMethodValue(contentfield); String extend = oConvertUtils.getString(reflectHelper.getMethodValue("extend")); String attachmenttitle = oConvertUtils.getString(reflectHelper.getMethodValue("attachmenttitle")); uploadFile.setExtend(extend); uploadFile.setTitleField(attachmenttitle); uploadFile.setRealPath(fileUrl); uploadFile.setContent(content); //uploadFile.setView(true); systemService.viewOrDownloadFile(uploadFile);