title: Not allowed to load local resource: Why?
body: <p>When a request for main.do comes in, it reads the file in the folder path. We then put the loaded file into the ModelAndView object and pass it to the main.jsp page.</p>
  
  <p><strong>Controller.java</strong></p>
  
  <pre><code>@RequestMapping("main.do")
  public ModelAndView mainPage(HttpSession session)
  {
      ModelAndView mav = new ModelAndView();
  
      mav.addObject("slideList", aService.readSlideFileList("slide"));
      mav.setViewName("mainPage");
  
      return mav;
  }
  </code></pre>
  
  <p><strong>Service.java</strong></p>
  
  <pre><code>public List&lt;HashMap&lt;String, Object&gt;&gt; readSlideFileList(String way)
      {
          File dir = new File(path + way + "/");
  
          if(!dir.isDirectory())
              dir.mkdirs();
  
          File[] fileList = dir.listFiles();
  
          //List&lt;String&gt; list = new ArrayList&lt;String&gt;();
          List&lt;HashMap&lt;String, Object&gt;&gt; list = new ArrayList&lt;HashMap&lt;String, Object&gt;&gt;();
          for (File file : fileList)
          {
              HashMap&lt;String,Object&gt; map = new HashMap&lt;String, Object&gt;();
              if (file.isFile())
              {
                  map.put("filePath", file.getName());
                  System.out.println("map &gt; " + map);
              }
              list.add(map);
          }
          return list;
      }
  </code></pre>
  
  <p>When I first tried this, I got an error like the title, so I wrote something like this:</p>
  
  <pre><code>if (file.isFile())
  {
      map.put("filePath", path + way + "/" + file.getName());
      System.out.println("map &gt; " + map);
  }
  </code></pre>
  
  <p>As a result, the resulting value of map is:</p>
  
  <pre><code>map &gt; C:/rachel/slide/"file name"
  </code></pre>
  
  <p>I tried to display this map manually. (As show below:)</p>
  
  <pre><code>&lt;c:forEach items="${slideList}" var="slideName"&gt;
      &lt;div class="swiper-slide"&gt;
          &lt;img src="${slideName.filePath}"/&gt;
      &lt;/div&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>The above results are expressed in Google Developer Tools.</p>
  
  <pre><code>&lt;img src="C:/rachel/"file path"&gt;
  </code></pre>
  
  <p>However, this causes an error such as a title.</p>
  
  <p>So I tried the following.</p>
  
  <p><strong>Server.xml</strong></p>
  
  <pre><code>&lt;Context docBase="rachelivf" path="/rachelivf" reloadable="true" source="org.eclipse.jst.jee.server:rachelivf"/&gt;
   &lt;!-- &lt;Context docBase="C:/rachel" path="/boardFile" reloadable="ture"/&gt; --&gt;
   &lt;Context docBase="C:/rachel" path="/slide" reloadable="true"/&gt;
  </code></pre>
  
  <p><strong>dispatcher-servlet.xml</strong></p>
  
  <pre><code>&lt;mvc:resources location="/slide/**" mapping="c:/rachel/**"&gt;&lt;/mvc:resources&gt;
  </code></pre>
  
  <p><strong>main.jsp</strong></p>
  
  <pre><code>&lt;c:forEach items="${slideList}" var="slideName"&gt;
      &lt;div class="swiper-slide"&gt;
          &lt;img src="/slide/${slideName.filePath}"/&gt;
      &lt;/div&gt;
  &lt;/c:forEach&gt;
  </code></pre>
  
  <p>(Modify the service logic again)</p>
  
  <pre><code>    if (file.isFile())
      {
          map.put("filePath", file.getName());
          System.out.println("map &gt; " + map);
      }
  </code></pre>
  
  <p>As a result, the error has changed.</p>
  
  <pre><code>Failed to load resource: the server responded with a status of 404 ()
  </code></pre>
  
  <p>In fact, as you've seen from Google developer tools,
  The  tag is expressed as:</p>
  
  <pre><code>&lt;img src="/slide/2f03c6f8-f5c1-4e6b-bf1c-c70398c118d4.png"&gt;
  </code></pre>
  
  <p>How do I display an image? I don t know what I'm doing wrong.</p>
  
  <p>Tell us what you think. </p>
  
  <p>I need help.</p>