No such file or directory when exporting excel from poi
Scene reproduction
Apache POI Linux Tomcat
As shown above, in the Linux + Tomcat environment, when exporting excel using Apache POI, an error of "no such file or directory" will be reported.
error message
Solution
Let's talk about the solution first, because the solution is very simple. You only need to create a "temp" folder under the root directory of Tomcat.
Error reason
The reason why this error occurs is that POI exports the exported Excel to the temporary directory of the system by default. At that time, the temp folder did not exist under the Tomcat of Linux, so the directory could not be found. In fact, no matter what system environment, this will happen as long as there is no temp in the Tomcat root directory. Take a look at the source code of POI below, and you will understand.
The above is the whole content of this article. I hope it will be helpful to your study, and I hope you can support programming tips.