如何创建CommonsMultipartFile实例

时间:2017-08-14 11:51:22

标签: spring spring-mvc file-upload

我尝试通过这种方式创建CommonsMultipartFile实例,但发生了java.lang.NullPointerException。

 DiskFileItemFactory factory = new DiskFileItemFactory(1024*1024,null);
 FileItem fileitem = factory.createItem("file", "application/vnd.ms-excel;charset=utf-8", true, "d:\\a.xls");//Method threw 'java.lang.NullPointerException' exception. Cannot evaluate org.apache.commons.fileupload.disk.DiskFileItem.toString()
    CommonsMultipartFile commonFile=new CommonsMultipartFile(fileitem);

1 个答案:

答案 0 :(得分:0)

您无法将Host 10.10.10.15 StrictHostKeyChecking no 作为第二个参数传递给构造函数。

传递某种临时文件夹,如下所示:

null