Failed to parse multipart servlet request; nested exception is java.io.IOException

org.springframework.web.multipart.MultipartException: Failed to parse multipart servlet request; nested exception is java.io.IOException: The temporary upload location [/tmp/tomcat.9158700952024484743.9080/work/Tomcat/localhost/ROOT] is not valid     at org.

  Problem: once a springboot abnormal encountered in the development, as follows: Failed to the parse multipart the servlet Request; nested Exception IS java.io.IOException: the Upload the Temporary LOCATION at The [/tmp/tomcat.1428942566812653608

 

Second, analysis cause

1. The exception is how to generate

I was through gentman, send a post request, causing the exception. Abnormality information from the above point of view, because the directory [/tmp/tomcat.1428942566812653608.8090/work/Tomcat/localhost/ROOT], due to the absence.

2. The abnormal why I will have no application to upload a file, why would throw an exception org.springframework.web.multipart.MultipartException
2.1) First of all, we should know that for the http POST requests, it needs to use this temporary directory post data to store.
2.2) Second, because the temporary file directory is hanging on to the next / temp directory, then for some OS system, like centOS will often delete the temporary directory, all resulting in the directory does not exist

Third, the solution

1. Restart your project on it (which I used)

You can also try the following ways

2. application.yml file set multipart location, and restart the project

 
  1. spring:

  2. http:

  3. multipart:

  4. location: /data/upload_tmp

 

3. Add a startup parameter -java.tmp.dir = / path / to / application / temp /, and reboot

☛ encounter after 3s in solving this problem

Released three original articles · won praise 1 · views 2498

Guess you like

Origin blog.csdn.net/weixin_42304280/article/details/104017920