1

I'm working on a web based application with Spring MVC and Thymeleaf. I have form which upload image. I decided to save the images in src/main/resources/static/images/ and that works perfect. But I found an issue with upload. When I save new image and try to display it in the HTML it's now working. When i refresh the images folder from STS and refresh the page it works fine. Can you give me some advice why this is happening and is there a way to fix it? I know i can use java code to get image content and display it as a resource but i would like to use thymeleaf's EL. I display the image with @{/images/imagename.jpg}

Best regards, Peter

Petar Petrov
  • 591
  • 2
  • 11
  • 28
  • Images are always cached by the browsers. This may help you: http://stackoverflow.com/questions/728616/disable-cache-for-some-images – PeterMmm Nov 08 '16 at 12:18

1 Answers1

1

The thing is, if your resources are within your web app, you won't be able to display it and change it at will. When you refresh your images folder on STS, it "redeploys" the resources and you can see your images.

What you need to do is to put your static/images folder outside your web app, then you'll be able to easily upload a new image and have it displayed on your web app

DamCx
  • 1,030
  • 1
  • 12
  • 22