title: Spring MVC Static Resource Sometimes Can't Find
body: <p>First, Sorry about my poor english</p>
  
  <p>=================================</p>
  
  <p>My static resource in '/resource/images/test1/image1.png'</p>
  
  <p>When "test1" folder is exist</p>
  
  <p>I can call '127.0.0.1:8080/myproject/resource/test1/image1.png' find it</p>
  
  <p>if i call '127.0.0.1:8080/myproject/resource/test1/image1.png' when folder not exist yet</p>
  
  <p>of course i can't find it</p>
  
  <p>but even i call url when after dynamically create folder </p>
  
  <p>i still can't got image </p>
  
  <p>EX1:</p>
  
  <p>Call url before create folder and call again after dynamically create folder </p>
  
  <p>------ <strong>Can't find, Only Get 404 Not Found</strong></p>
  
  <p>EX2:</p>
  
  <p>Create folder before call url and call again </p>
  
  <p>------ <strong>Can find</strong></p>
  
  <p>I thought it was a cache problem at first</p>
  
  <p>But when EX1 problem occur, stall occur even change browser</p>
  
  <p>Both EX are deployment on linux</p>
  
  <p>I have the following Setting</p>
  
  <p>web.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"&gt;  
    &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;/WEB-INF/base-config.xml&lt;/param-value&gt;
    &lt;/context-param&gt;
  
    &lt;servlet&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
    &lt;/servlet&gt;
  
    &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;dispatcher&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
    &lt;/servlet-mapping&gt;
    &lt;session-config&gt;
      &lt;session-timeout&gt;120&lt;/session-timeout&gt;
    &lt;/session-config&gt;
    &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
    &lt;/listener&gt;
    &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;signin&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>dispatcher-servlet.xml</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
   ........
   ........
   ........
  &lt;mvc:annotation-driven /&gt;
  &lt;context:component-scan
      base-package="com.chat.controller" /&gt;
  &lt;mvc:resources mapping="/resource/**" location="/resource/" cache-period="0"/&gt;   
  
  
  &lt;!-- jsp views --&gt;
  &lt;bean id="viewResolver"
      class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt;
      &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt;
      &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>