1 //文件 2 private File file; 3 //文件名称 4 private String fileFileName; 5 private String fileContentType; 6 7 8 /* 9 * 添加方法 10 */ 11 public String districtSave(){ 12 try { 13 if(file!=null){ 14 String tem_path = this.contextPvd.getAppRealPath(Util.FILE_FOLDER); 15 String file_name = UploadFile.copy(file, tem_path, this.getFileFileName()); 16 String path = Util.FILE_FOLDER+File.separator+file_name;//原始图片保存路径 17 districtTest.setUpload(path); 18 19 /*//上传文件路径 20 String path = Util.FILE_FOLDER+"/"+Util.DOWN+"/"; 21 //文件名称重命名 22 String file_name = UtilMethod.generateFileName(myFileFileName); 23 File uploadFile = new File(ServletActionContext.getServletContext().getRealPath(path), file_name); 24 if(!uploadFile.exists()){ 25 FileUtils.copyFile(myFile, uploadFile); 26 } 27 districtTest.setUpload(path+file_name);*/ 28 } 29 districtTest.setCreateTime(new Date()); 30 districtTest.setUpdateTime(new Date()); 31 districtTest.setIsDele(0); 32 this.utilService.save(districtTest); 33 Loggers.logToDB("执行了添加区县操作", contextPvd.getSessionId(Util.SESSION_SYS_USER), Util.CREATE); 34 return districtList(); 35 } catch (Exception e) { 36 // TODO: handle exception 37 Loggers.error("----DistrictTestAction的districtSave方法错误"+e.getMessage()); 38 e.printStackTrace(); 39 } 40 return ERROR; 41 }