title: How to get image file path in Spring mvc project?
body: <p><a href="https://i.stack.imgur.com/fxHPH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fxHPH.png" alt="package explorer"></a></p>
  
  <p>What my problem is that I can't get image path from the resource folder to main package in spring project. My code is like below. </p>
  
  <pre><code>  for (int i = 0; i &lt; SUITE; i++) {
          for(int j = 0; j &lt; FACE ; j++){
  
              Card card = new Card();
              BufferedImage temp = null;
              Resource resource = new FileSystemResource("src/main/webapp/resources/img/cards/" + faces[j] + "_of_" + suite[i] + ".png");
              card.setSuite(suite[i]);
              card.setFace(faces[j]);
              card.setValue(values[j]);
              card.setPath(resource.getFilename());
  
              try {
                  temp = ImageIO.read(new File(card.getPath()));
              } catch (IOException e) {
                  e.printStackTrace();
              }
              card.setImg(temp);
              deck.add(card);
          }
      }
  </code></pre>