public void cleanupMultipart(MultipartHttpServletRequest request) { if (request != null) { try { cleanupFileItems(request.getFileMap().values()); } catch (Throwable ex) { logger.warn("Failed to perform multipart cleanup for servlet request", ex); } } }
/** * 文件上传表单 * @param request * @param response * @return */ public ModelAndView fileUploadForm(MultipartHttpServletRequest request,HttpServletResponse response){ MultipartFile file = request.getFile("test"); try { File dir = new File("d:/mutifiles/"); if(!dir.exists()) dir.mkdirs(); file.transferTo(new File("d:/mutifiles/" + file.getOriginalFilename())); String fileName=file.getOriginalFilename(); return new ModelAndView("path:fileUploadForm-success","fileName",fileName); } catch (IllegalStateException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } return new ModelAndView("path:fileUploadForm-error"); }