Package org.springframework.web.multipart

Examples of org.springframework.web.multipart.MultipartFile


  @RequestMapping(params = "implXls")
  @ResponseBody
    public AjaxJson implXls(HttpServletRequest request, HttpServletResponse response) {
        AjaxJson j = new AjaxJson();
        MultipartHttpServletRequest mulRequest = (MultipartHttpServletRequest) request;
        MultipartFile file = mulRequest.getFile("filedata");
        List<JpPersonEntity> listPersons;
    try {
      boolean isSuccess = true;
      listPersons = (List<JpPersonEntity>) ExcelUtil.importExcelByIs(file.getInputStream(), JpPersonEntity.class);
      for (JpPersonEntity person : listPersons) {
        person.setId(UUIDGenerator.generate());
        if (person.getAge() == null || person.getCreatedt() == null || person.getSalary() == null) {
          isSuccess = false;
          break;
View Full Code Here


    AjaxJson j = new AjaxJson();
   
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
    for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
      MultipartFile file = entity.getValue();// 获取上传文件对象
      List<JpPersonEntity> listPersons;
      try {
        listPersons = (List<JpPersonEntity>) ExcelUtil.importExcelByIs(file.getInputStream(), JpPersonEntity.class);
        for (JpPersonEntity person : listPersons) {
          if(person.getAge()!=null){
            person.setId(UUIDGenerator.generate());
            jpPersonService.save(person);
          }
View Full Code Here

        }
      }
      LogUtil.info("-------------------------step.3-------------------------------------");
      String fileName = "";
      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
        MultipartFile mf = entity.getValue();// 获取上传文件对象
        fileName = mf.getOriginalFilename();// 获取文件名
        String extend = FileUtils.getExtend(fileName);// 获取文件扩展名
        String myfilename = "";
        String myhtmlfilename = "";
        String noextfilename = "";// 不带扩展名
        if (uploadFile.isRename()) {

          noextfilename = DataUtils
              .getDataString(DataUtils.yyyymmddhhmmss)
              + StringUtil.random(8);// 自定义文件名称
          myfilename = noextfilename + "." + extend;// 自定义文件名称
        } else {
          myfilename = fileName;
        }

        String savePath = realPath + myfilename;// 文件保存全路径
        cgformFtl.setFtlWordUrl(fileName);
        File savefile = new File(savePath);
        FileCopyUtils.copy(mf.getBytes(), savefile);

        myhtmlfilename = realPath + noextfilename + ".html";
        String myftlfilename = realPath + noextfilename + ".ftl";
        LogUtil.info("-------------------------step.4-------------------------------------");
        // 开始转换表单文件
View Full Code Here

      MultipartHttpServletRequest multipartRequest = uploadFile
          .getMultipartRequest();
      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
      String fileName = "";
      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
        MultipartFile mf = entity.getValue();// 获取上传文件对象
        fileName = mf.getOriginalFilename();// 获取文件名
        String savePath = realPath + fileName;
        File savefile = new File(savePath);
        String ls_tmp = savefile.getName();
        /*String sqlfilename = realPath
            + ls_tmp.substring(0, ls_tmp.lastIndexOf(".")) + "\\"
            + ls_tmp.substring(0, ls_tmp.lastIndexOf(".")) + ".sql";*/
        FileCopyUtils.copy(mf.getBytes(), savefile);
        MigrateForm.unzip(savePath, "");
        String sqlFileDir = realPath + ls_tmp.substring(0, ls_tmp.lastIndexOf("."));
        File sqlDirFile = new File(sqlFileDir);
        String sqlfilename = sqlDirFile.getPath() + "/";
        if(sqlDirFile.isDirectory()){
View Full Code Here

      MultipartHttpServletRequest multipartRequest = uploadFile
          .getMultipartRequest();
      Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
      String fileName = "";
      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
        MultipartFile mf = entity.getValue();// 获取上传文件对象
        fileName = mf.getOriginalFilename();// 获取文件名
        String savePath = realPath + fileName;
        File savefile = new File(savePath);
        String ls_tmp = savefile.getName();
        FileCopyUtils.copy(mf.getBytes(), savefile);
        MigrateForm.unzip(savePath, "");
        String sqlFileDir = realPath + ls_tmp.substring(0, ls_tmp.lastIndexOf("."));
        File sqlDirFile = new File(sqlFileDir);
        String sqlfilename = sqlDirFile.getPath() + "/";
        if(sqlDirFile.isDirectory()){
View Full Code Here

    AjaxJson j = new AjaxJson();
   
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
    for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
      MultipartFile file = entity.getValue();// 获取上传文件对象
      ImportParams params = new ImportParams();
      params.setTitleRows(2);
      params.setSecondTitleRows(2);
      params.setNeedSave(true);
      try {
        List<CourseEntity> listCourses =
          (List<CourseEntity>)ExcelImportUtil.importExcelByIs(file.getInputStream(),CourseEntity.class,params);
        for (CourseEntity course : listCourses) {
          if(course.getName()!=null){
            courseService.saveCourse(course);
          }
        }
        j.setMsg("文件导入成功!");
      } catch (Exception e) {
        j.setMsg("文件导入失败!");
        logger.error(ExceptionUtil.getExceptionMessage(e));
      }finally{
        try {
          file.getInputStream().close();
        } catch (IOException e) {
          e.printStackTrace();
        }
      }
    }
View Full Code Here

  private List<MultipartFile> getMultipartFiles(MultipartHttpServletRequest request) {
    List<MultipartFile> files = new ArrayList<MultipartFile>();
    Map<String, MultipartFile> fMap = request.getFileMap();
    for (String fileName : fMap.keySet()) {
      MultipartFile fileItem = fMap.get(fileName);
      if (fileItem.getSize() > 0) {
        files.add(fileItem);
      }
    }
    return files;
  }
View Full Code Here

    AjaxJson j = new AjaxJson();
   
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
    for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
      MultipartFile file = entity.getValue();// 获取上传文件对象
      try {
        jeecgBlobDataService.saveObj(documentTitle, file);
        j.setMsg("文件导入成功!");
      } catch (Exception e) {
        j.setMsg("文件导入失败!");
View Full Code Here

    AjaxJson j = new AjaxJson();
   
    MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
    Map<String, MultipartFile> fileMap = multipartRequest.getFileMap();
    for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
      MultipartFile file = entity.getValue();// 获取上传文件对象
      try {
        webOfficeService.saveObj(webOffice, file);
        j.setMsg("文件导入成功!");
      } catch (Exception e) {
        j.setMsg("文件导入失败!");
View Full Code Here

        path = uploadFile.getCusPath() + "/";
      }
      String fileName = "";
      String swfName = "";
      for (Map.Entry<String, MultipartFile> entity : fileMap.entrySet()) {
        MultipartFile mf = entity.getValue();// 获取上传文件对象
        fileName = mf.getOriginalFilename();// 获取文件名
        swfName = PinyinUtil.getPinYinHeadChar(oConvertUtils.replaceBlank(FileUtils.getFilePrefix(fileName)));// 取文件名首字母作为SWF文件名
        String extend = FileUtils.getExtend(fileName);// 获取文件扩展名
        String myfilename="";
        String noextfilename="";//不带扩展名
        if(uploadFile.isRename())
        {
          
           noextfilename=DataUtils.getDataString(DataUtils.yyyymmddhhmmss)+StringUtil.random(8);//自定义文件名称
           myfilename=noextfilename+"."+extend;//自定义文件名称
        }
        else {
          myfilename=fileName;
        }
       
        String savePath = realPath + myfilename;// 文件保存全路径
        String fileprefixName = FileUtils.getFilePrefix(fileName);
        if (uploadFile.getTitleField() != null) {
          reflectHelper.setMethodValue(uploadFile.getTitleField(), fileprefixName);// 动态调用set方法给文件对象标题赋值
        }
        if (uploadFile.getExtend() != null) {
          // 动态调用 set方法给文件对象内容赋值
          reflectHelper.setMethodValue(uploadFile.getExtend(), extend);
        }
        if (uploadFile.getByteField() != null) {
          // 二进制文件保存在数据库中
          reflectHelper.setMethodValue(uploadFile.getByteField(), StreamUtils.InputStreamTOByte(mf.getInputStream()));
        }
        File savefile = new File(savePath);
        if (uploadFile.getRealPath() != null) {
          // 设置文件数据库的物理路径
          reflectHelper.setMethodValue(uploadFile.getRealPath(), path + myfilename);
        }
        saveOrUpdate(object);
        // 文件拷贝到指定硬盘目录
        FileCopyUtils.copy(mf.getBytes(), savefile);
//        if (uploadFile.getSwfpath() != null) {
//          // 转SWF
//          reflectHelper.setMethodValue(uploadFile.getSwfpath(), path + swfName + ".swf");
//          SwfToolsUtil.convert2SWF(savePath);
//        }
View Full Code Here

TOP

Related Classes of org.springframework.web.multipart.MultipartFile

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.