title: How to load an image using absolute path in Spring MVC?
body: <p>I have images on my file server, and the locations of the images stored in the database. Let's say all my images are stored in folder </p>
  
  <p><code>C:\Users\myuser\Desktop\images\</code></p>
  
  <p>and I have following rows in my database</p>
  
  <p><code>C:\Users\myuser\Desktop\images\image1.png</code>
  <code>C:\Users\myuser\Desktop\images\image2.png</code></p>
  
  <p>I want to display the images on a JSP page, using Spring MVC via annotations</p>
  
  <p>I have configured the resource handler for the image folder</p>
  
  <pre><code>@Override
  public void addResourceHandlers(ResourceHandlerRegistry registry) {
      registry.addResourceHandler("/images/**").addResourceLocations("file:C:/Users/myuser/Desktop/images/");
  }
  </code></pre>
  
  <p>and i'm passing the file path loaded from database to the jsp file</p>
  
  <p>here's how i want to display it</p>
  
  <pre><code>&lt;c:forEach var="imgPath" items="${imagesList}"&gt;
      &lt;img src="/images/${imgPath}" alt=""&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>I tried saving just file name in the database, or remove the <code>/images/</code> resource handler, and non of the methods works. How should I store my file names, and how do i access the files from some absolute path on my computer?</p>