/** 下载 */ public String download() throws Exception { // 准备下载的资源 ApplicationTemplate applicationTemplate = applicationTemplateService.getById(model.getId()); inputStream = new FileInputStream(applicationTemplate.getPath()); // 准备文件名(解决乱码问题) String fileName = URLEncoder.encode(applicationTemplate.getName(), "utf-8"); ActionContext.getContext().put("fileName", fileName); return "download"; }
/** 修改 */ public String edit() throws Exception { // 1、从数据库中找到对应的id的对象 ApplicationTemplate applicationTemplate = applicationTemplateService.getById(model.getId()); // 2、设置需要修改的属性 applicationTemplate.setName(model.getName()); applicationTemplate.setProcessDefinitionKey(model.getProcessDefinitionKey()); // 表示有重新上传文件 if (upload != null) { // 删除老文件 File file = new File(applicationTemplate.getPath()); if (file.exists()) { file.delete(); } // 使用新文件 String path = saveUploadFile(upload); applicationTemplate.setPath(path); } applicationTemplateService.update(applicationTemplate); return "toList"; }