Spring上传文件代码片段

Controller上传文件

   if (file != null) {
                String path = Global.getProperty(WebConstants.BUSINESS_FILE_SAVE_DIR) + Global.getProperty(WebConstants.PROJECT_FILE_SAVE_DIR);
                String dbFileName = GetUtil.getUUID() + "_" + DateUtils.getCurrentDateYYYYMMDDHHMMSSContinus() + "." + FileUtil.getFileExtension(file.getOriginalFilename());
                File targetFile = new File(path, dbFileName);
                if (!targetFile.exists()) {
                    targetFile.mkdirs();
                }
                file.transferTo(targetFile);
                technicalBasis.setTb_db_filename(dbFileName);
                technicalBasis.setTb_real_filename(file.getOriginalFilename());
            }

你可能感兴趣的:(Spring上传文件代码片段)