The image has been uploaded, but it doesn't appear on the screen! ??


Upload images using Spring Boot. Immediately after uploading, the image is not displayed on the HTML, but it is displayed when the screen is refreshed after waiting for about 30 seconds.

How to upload an image

Image file-> / resource / static / images / File name (file name such as xxx-20200712151409.jpg)-> Store in DB


  1. Create a folder (temporarily called images) directly under the root folder This time, images are created directly under the root folder called Ramen Kingdom. スクリーンショット 2020-07-12 15.17.29.png

  2. Create a WebConfiguration class (assumed to be AdditionalResourceWebConfiguration)

public class AdditionalResourceWebConfiguration implements WebMvcConfigurer {

    public void addResourceHandlers(ResourceHandlerRegistry registry) {

After that, just change the code that stored the images to images directly under the root folder. However, on HTML, you need to do the following:

<img th:src="@{'/images/' + ${picture.filepath}}"/>


Files that change dynamically like this time are not stored under static! !! !!

that's all. Thank you for reading to the end.

Recommended Posts

The image has been uploaded, but it doesn't appear on the screen! ??
Display an image on the base64 screen