When using Tomcat as a server, if you do not configure the picture to save the path, the picture is saved in the project path, then the war Package publishing project may cause the loss of the picture, each restart before the picture saved and then copy to the server is obviously inconvenient, you can configure the picture save location, Save the picture to a place outside of the project, by doing the following:
Open the Server.xml file under tomcat-conf and add it under the host node
<context docbase= "G:/upload/images" path= "/images"/>
Docbase is the location where the picture is saved, and path is the way to access the picture.
For example: Upload a picture of test.jpg to the server,
Access Path is http://localhost/images/test.jpg
This not only solves the picture preservation problem, but also can ensure the security of the server.
To achieve a demand, the mobile upload image to the server, the mobile side using Base64 encoding, transmission, service-side decoding, save to disk C:/picture, the mobile end of the request again or return to Base64 past, want to make the image in a URL representation.
Only one simple configuration is required here:
1. Go to Tomcat's installation path to locate the configuration file, and then modify
Locate Server.xml for the following configuration
<Context path="/image" docBase="C:\picture" debug="0" reloadable="true" crossContext="true" />
2. Go to eclipse, locate the Tomcat server under which you are running the project, click and a page will appear, and the page can see the Overview/modules
3. Click Modules, click Add External Web Module, and then enter the path where you stored the image, such as c:/picture, and then restart the server.
Then in the browser input your ip+ set path name + picture, such as I set c:/picture not called/picture, my picture is test.png;
Then I can be ip+/picture/test.png when I visit.
URL access to a picture in Tomcat that implements a specific path