Modify the output path of tomcat in IntelliJ IDEA


         When doing the file upload function test, I found that there is no problem with the file upload function, but when reading the uploaded file (picture), it prompts that the path cannot be found, but there is a phenomenon that it can be displayed successfully after restarting the Tomcat server. After analyzing the reason, I guess it is Since there is no mention of uploading pictures to the server directory, the file cannot be found when the server is running, but after restarting the server, it is equivalent to redeploying the project again, so the uploaded files or pictures are deployed to the server along with the project. So the file or picture can be displayed successfully.

        After realizing the problem, I don't know how to solve it. Searching on Baidu is fruitless. It seems that there has never been a similar problem. One of the strange things about IDEA is that the default output path is in the target folder under this project, so I found the corresponding path under the corresponding webapp folder in the target folder, and set the path of the uploaded file to this folder, Then modify the corresponding file display path, still shows that the file cannot be found.

        So I wanted to try if I could change the project deployment path to the webapp folder in the server directory (like the previous development using MyEclipse), and through my efforts, I finally successfully modified the output path, and modified the corresponding file upload path, and then tested as The user has newly registered an avatar that has never been used before, log in, and the exciting time has come! ! The picture is displayed successfully! ! ! First put the method and process screenshots of modifying the output path in the blog post for future reference and others.


         


 

 

 
         At this point, try to restart the Tomcat server. After startup, go to the server directory to find out whether there is a project written by yourself. If there is, try to modify the file upload path to the path of a folder under the current server, and then try the function on the webpage. use, the problem may be solved

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326505167&siteId=291194637