title: display image from file system in jsp using spring boot
body: <p>I have Java Web Application using Spring Boot, I want to display in JSP page ,images  which are in an extern folder (E:/images) in file system. 
  I looked too many pages in google,I found on stackoverflow a post that say I should write a servlet to get the image  : am I missing something or should I do it with an other way , please give me more details I m kind of new to Spring. thanks for your help.</p>
  
  <p>in my Controller :</p>
  
  <pre><code>@RequestMapping(value="/images",method = RequestMethod.GET)
      public @ResponseBody void affichimage(@RequestParam("id") Integer Iddd,HttpServletResponse response,HttpServletRequest request) throws IOException
      {
          Annonce annonce=new Annonce();
          annonce=annoncedao.findOne(Iddd);  // get the right annonce from 
           //database
           File imageFile = new File(annonce.getimage()); // in image I have 
              //the  link to images  ex : E:/images/image1.jpeg
          response.setContentType("image/jpeg");
  
          BufferedImage image = ImageIO.read(imageFile);
          ImageIO.write(image, "image/jpeg", response.getOutputStream());
      }
  </code></pre>
  
  <p>in JSP :</p>
  
  <pre><code>&lt;  img class="imagesaffichage" src="/images?id=${annonce.id}" alt="No  image"/&gt;
  </code></pre>
  
  <p>I also added this to my application :</p>
  
  <pre><code>public void addResourceHandlers(ResourceHandlerRegistry registry) {
          registry.addResourceHandler("/resources/**")
                  .addResourceLocations("file:///E:/images/");
      }
  </code></pre>