⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 1-2.txt

📁 一次上传多个文件。 允许得到上传的文件的原文件名
💻 TXT
字号:
  protected ModelAndView onSubmit(HttpServletRequest request,
            HttpServletResponse response, Object cmd, BindException errors)
            throws Exception {

            FileUploadBean bean = (FileUploadBean) cmd;
            byte[] bytes = bean.getFile();
           
            //cast to multipart file so we can get additional information
            MultipartHttpServletRequest multipartRequest = (MultipartHttpServletRequest) request;
            CommonsMultipartFile file = (CommonsMultipartFile) multipartRequest.getFile("file");

            String uploadDir = this.getUploadDir();

            File dirPath = new File(uploadDir);
            if (!dirPath.exists()) {
                dirPath.mkdirs();
            }
            String sep = System.getProperty("file.separator");
            if (log.isDebugEnabled()) {
                log.debug("uploading to: " + uploadDir + sep +
                file.getOriginalFilename());
                }
            File uploadedFile = new File(uploadDir + sep
                    + file.getOriginalFilename());
            FileCopyUtils.copy(bytes, uploadedFile);
            System.out.println("********************************");
            System.out.println(uploadedFile.getAbsolutePath());
            System.out.println(bytes.length);
            System.out.println("********************************");
            
      
        return new ModelAndView(getSuccessView() + ".jsp");
    }

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -