fileinput+Springboot的excel上传问题

前端用webstrom写,前后端分离。

后端代码:

@RequestMapping("upload.action")
public @ResponseBody String Daoru(@RequestParam(value="file",required=false) CommonsMultipartFile[] files, HttpServletResponse resp, HttpServletRequest request){
    //获取文件上传绝对路径
    String uploadPath = "E:\\abc";
    resp.setContentType("text/html");
    File baseFile = new File(uploadPath);
    String fileName = "";
    if(!baseFile.exists()){
        baseFile.mkdirs();
    }
    try{
        if(files!=null){
            for(int i=0;ilength;i++){
                if(StringUtil.isblank(files[i].getOriginalFilename())){
                    continue;
                }
                fileName = files[i].getOriginalFilename();
                String filePath =  uploadPath + "/" + fileName;
                files[i].transferTo(new File(filePath));
            }
        }
        resp.flushBuffer();
        //遍历本地的excel,获取sheet名称以及sheet在poi中的值
        String localPath = uploadPath+ "/" + fileName;
        //List sheetName = ExcelUtil.getSheetName(localPath);

        //String list2json = JsonChangeUtil.list2json(sheetName);
       /* return JsonChangeUtil.string2json(this.importExcel(localPath));*/
    }catch(Exception e){
        return null;
    }
    return "true";

}

出现问题:*********************************过滤器被使用************************** 2018-07-06 11:44:32,821:WARN http-nio-8082-exec-1 (DefaultHandlerExceptionResolver.java:375) - Failed to convert request element: org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException: Failed to convert value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile' to required type 'org.springframework.web.multipart.commons.CommonsMultipartFile[]'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile' to required type 'org.springframework.web.multipart.commons.CommonsMultipartFile': no matching editors or conversion strategy found 2018-07-06 11:44:32,825:WARN http-nio-8082-exec-1 (AbstractHandlerExceptionResolver.java:193) - Resolved exception caused by Handler execution: org.springframework.web.method.annotation.MethodArgumentConversionNotSupportedException: Failed to convert value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile' to required type 'org.springframework.web.multipart.commons.CommonsMultipartFile[]'; nested exception is java.lang.IllegalStateException: Cannot convert value of type 'org.springframework.web.multipart.support.StandardMultipartHttpServletRequest$StandardMultipartFile' to required type 'org.springframework.web.multipart.commons.CommonsMultipartFile': no matching editors or conversion strategy found 已跨域

后端方法断点都没进!!!!

你可能感兴趣的:(fileinput+Springboot的excel上传问题)