zoukankan      html  css  js  c++  java
  • SpringMVC Ueditor1.4.3 未找到上传数据

    ueditor自事的fileupload组件与spring的有冲突。将那个类BinaryUploader 重写就可以了

                return storageState;
            } catch (FileUploadException e) {
                return new BaseState(false, AppInfo.PARSE_REQUEST_ERROR);
            } catch (IOException e) {
            }
            return new BaseState(false, AppInfo.IO_ERROR);
        }*/
        
        public static final State save(HttpServletRequest request,
                Map<String, Object> conf) {

            try {
                MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
                MultipartFile multipartFile = multipartRequest.getFile(conf.get("fieldName").toString());

                String savePath = (String) conf.get("savePath");
                String originFileName = multipartFile.getOriginalFilename();
                String suffix = FileType.getSuffixByFilename(originFileName);

                originFileName = originFileName.substring(0,originFileName.length() - suffix.length());
                savePath = savePath + suffix;

                long maxSize = ((Long) conf.get("maxSize")).longValue();

                if (!validType(suffix, (String[]) conf.get("allowFiles"))) {
                    return new BaseState(false, AppInfo.NOT_ALLOW_FILE_TYPE);
                }
                /***********/
                //自定义
                savePath = PathFormat.parse(savePath, originFileName);
               
                String [] savePathBySplit_temp = savePath.split("/");
                String temp = "";
                String fileName = savePathBySplit_temp[savePathBySplit_temp.length-1];
                for(int i = 2;i < savePathBySplit_temp.length-1; i++){
                    if(i!=savePathBySplit_temp.length-2){
                        temp+=savePathBySplit_temp[i]+"/";
                    }else{
                        temp+=savePathBySplit_temp[i];
                    }
                }
                String pathTemp = request.getSession().getServletContext().getRealPath(temp);
                System.out.println(pathTemp+","+fileName);
                System.out.println(new File(pathTemp).exists());
                File targetFile = new File(pathTemp);
                if(!targetFile.exists()){  
                    targetFile.mkdirs();  
                }
                System.out.println(new File(pathTemp).exists());
                /************/
                //State storageState = StorageManager.saveFileByInputStream(multipartFile.getInputStream(),savePath, maxSize);
                State storageState = StorageManager.saveFileByInputStream(multipartFile.getInputStream(),pathTemp+"/"+fileName, maxSize);

                if (storageState.isSuccess()) {
                    storageState.putInfo("url", PathFormat.format(savePath));
                    storageState.putInfo("type", suffix);
                    storageState.putInfo("original", originFileName + suffix);
                }

                return storageState;

            }catch (Exception e) {
                e.printStackTrace();
                System.out.println(e.getMessage());
            }
            return new BaseState(false, AppInfo.IO_ERROR);
        }
  • 相关阅读:
    C#编程语言详解(第2版) 11.3 类和结构的区别
    .Net程序员如何快速成长之我见
    封装 JMail 4.4 的 POP3 为 .Net 组件 (.dll 程序集),实现 "邮件(附件) 到达" 等 "事件,c#接收邮件
    POJ1163The Triangle
    hdoj_1231&&hdoj_1003最大连续子序列
    数组名++操作导致的_BLOCK_TYPE_IS_VALID
    《windows程序设计》第二章学习心得
    error LNK2019: unresolved external symbol _WinMain@16 referenced in function ___tmainCRTStartup
    Windows环境下Unicode编程总结
    已知顺序表L递增有序,写一算法,将X插入到线性表的适当位置,以保持线性表的有序
  • 原文地址:https://www.cnblogs.com/vincent4code/p/5809858.html
Copyright © 2011-2022 走看看