fryzjerro
fryzjerro

Reputation: 109

Spring MVC - referring an uploaded image

I have implemented an image uploading functionality. The problem is that I am saving these files outside an application (so that they won't be deleted in case of redeploy), and I don't really know how to refer them from a jsp file then, as I only know how to refer to the webapp (or resources) directory.

Upvotes: 1

Views: 290

Answers (1)

James W.
James W.

Reputation: 3055

Have you tried adding to server.xml under $CATALINA_HOME/config/server.xml

<Context docBase="/usr/local/tomcat/folder/with/images" path="/uploads/img" />

For example:If you have foo.jpg inside the

/usr/local/tomcat/folder/with/images directory

then you can access the foo.jpg file via

localhost:8081/uploads/img/foo.jpg

Upvotes: 1

Related Questions