java.lang.NullPointerException while creating DiskFileItem

前端 未结 5 1592
我寻月下人不归
我寻月下人不归 2021-01-13 04:14

I am trying to write a unit test for handling a file upload controller using Spring 3. Now if I send the image over to my service method through the controller everything wo

5条回答
  •  无人及你
    2021-01-13 05:03

    What does this part of this log say?

    log.info("found file: " +file.exists());
    log.info("file size: " +file.length());
    

    But I think the problem might be because of this:

    File file = new File("//Users//test//Downloads//");
    

    It looks like it's pointing to a directory instead of a file, so maybe that is why you are getting a NullPointerException when you want to get the size of DiskFileItem

提交回复
热议问题