简体   繁体   中英

When tomcat redeploy, the previous upload files are missing

I'm writing a website with the function file uploading. And the Path I save the file is by ServletActionContext.getServletContext().getRealPath("xxxx")

It will save the file to webapps/mywebsit/xxxx to allow the clients are able to access the data directly by http:// mywebsit/mebsite/xxxxx

the function is ok. But when it comes to redeploy on tomcat here comes the problem.

When I redeploy by war file . It seems sorts of remove the all webapps/mywebsit . And deploy it with the new war file . And the previous upload files are missing.

Is there anyway I can let tomcat don't remove my file while it's redeploying? Or I should store files outside the webapps? But how can I let client be able to reach the file?

When tomcat redeploys your application, it will remove it's directory under /webapps/ completely and unpack the WAR from scratch. TI'd recommend keeping your files outside the webapp's directory. You could try using environment variables to point your application to directory you'd like to use, taking care that the user tomcat runs under has appropriate access rights.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM