public class InterfaceServiceImplAction extends BaseFormBean{ private Map<String,Object> dataMap; private File file; private String fileFileName; private String appId; private DocBizManageBo docBizManageBo; private DocManageBo docManageBo; public String getEipAttachment4debt() { dataMap = new HashMap<String, Object>(); ActionContext.initialize(ServletActionContext.getRequest(), ServletActionContext.getResponse()); HttpServletRequest request = ServletActionContext.getRequest(); if(!ServletFileUpload.isMultipartContent(request)) { dataMap.put("code", "1"); dataMap.put("data", ""); return SUCCESS; } try { String path = UploadUtil.getFileUploadPath()+File.separator+"thirdReport4debt"; String fileName = appId+"-三方调查报告."+fileFileName.split("\\.")[1]; File paramFile = new File(path+File.separator+fileName); FileUtils.copyFile(file, paramFile); createAttachment(appId, fileName, path); } catch (UnsupportedEncodingException e) { e.printStackTrace(); } catch (IOException e1) { e1.printStackTrace(); } catch (Exception e) { e.printStackTrace(); } // ServletContext servletContext = ServletActionContext.getServletContext(); // MultipartResolver multipartResolver = new CommonsMultipartResolver(servletContext); // MultipartHttpServletRequest multipartHttpServletRequest = multipartResolver.resolveMultipart(request); // MultiValueMap<String, MultipartFile> multiFileMap = multipartHttpServletRequest.getMultiFileMap(); // Map<String, MultipartFile> fileMap = multipartHttpServletRequest.getFileMap(); // List<MultipartFile> files = multipartHttpServletRequest.getFiles("files"); // MultipartFile file = multipartHttpServletRequest.getFile("file"); // FileItemFactory fileItemFactory = new DiskFileItemFactory(); // ServletFileUpload servletFileUpload = new ServletFileUpload(fileItemFactory); // try { // List<FileItem> parseRequest = servletFileUpload.parseRequest(request); for(FileItem fileItem : parseRequest) { // if(!fileItem.isFormField()) { // String path = request.getSession().getServletContext().getRealPath(""); // File paramFile = new File("d:\\Users\\zhangyxi\\Desktop\\",fileItem.getName()); // fileItem.write(paramFile); // } // } // } catch (FileUploadException e) { // e.printStackTrace(); // } catch (Exception e) { // e.printStackTrace(); // } // try { // InputStream inputStream = fileMap.get("file").getInputStream(); // } catch (IOException e) { // e.printStackTrace(); // } // Iterator<String> iterator = multipartHttpServletRequest.getFileNames(); // while(iterator.hasNext()) { // System.out.println(iterator.next()); // } dataMap.put("code", "0"); dataMap.put("data", ""); return SUCCESS; }