In the development project, sometimes need to use the upload function, such as Avatar upload, and its files will be saved to the server. But I found that in the process of using eclipse as a project, every time I redeploy a project, the original uploaded file is lost.
The reason for this is that eclipse will copy the project we put in the workspace workspace to the server (such as Tomcat's WebApps directory) after each project is modified. Because the previously uploaded files are in the previous deployed project, the newly deployed project will cover the original project directly. The original uploaded files are gone.
Solution One:
Create a separate folder for resource files under the WebApps of the Tomcat server (XXX)
Upload files to this folder in the project.
To request a file, you can use http://localhost:8081/xxx/xxxxx.jpg directly
Solution Two:
Configure an empty project in the form of a virtual path. When it comes to uploading, write the file directly to the project where the virtual path is configured, and the final file is saved to the physical disk of the virtual path.
On If it's a tomcat server, configure it in Tomcat's server.xml. However, in the actual operation of the process, found that Server.xml will also be rewritten. Because there is one in the Eclipse workspace
Called the servers project, which has a file called Server.xml, which overwrites the Tomcat server when deploying the project. So, we can migrate the following configuration to
Under eclipse under the Servers project.
The following screenshot is located:
Configure under Host
Request http://www.***.com/objimags/filename. jpg, automatically to the D://objimgs//upload directory to find the relevant documents
Reference: http://bbs.csdn.net/topics/391868478