title: How to upload an image to webapp/resources/images directory using spring mvc?
body: <p>I have repository class where I want to store the image that is coming from MultipartFile to webapp/resources/images directory before adding the product details to the repository ?</p>
  
  <pre><code>@Override
  public void addProduct(Product product) {
      Resource resource = resourceLoader.getResource("file:webapp/resources/images");
  
       MultipartFile proudctImage = product.getProudctImage();
  
       try {
          proudctImage.transferTo(new File(resource.getFile()+proudctImage.getOriginalFilename()));
      } catch (IOException e) {
          throw new RuntimeException(e);
      }
      listOfProducts.add(product);
  }
  </code></pre>
  
  <p>my repository class is ResourceLoaderAware. I am getting fileNotFoundException, "imagesDesert.jpg" is the image I am trying to upload</p>
  
  <pre><code>java.io.FileNotFoundException: webapp\resources\imagesDesert.jpg (The system cannot find the path specified)
  </code></pre>