title: CSS file in a Spring WAR returns a 404
body: <p>I have a Java EE application that I am building with Spring and Maven. It has the usual project structure. Here is a bit of the hierarchy.</p>
  
  <pre><code>MyApplication
      src
          main
              webapp
                  WEB-INF
                      layout
                          header.jsp
                  styles
                      main.css
  </code></pre>
  
  <p>I want to include that CSS file in my JSP. I have the following tag in place.</p>
  
  <pre><code>&lt;c:url var="styleSheetUrl" value="/styles/main.css" /&gt;
  &lt;link rel="stylesheet" href="${styleSheetUrl}"&gt;
  </code></pre>
  
  <p>When I deploy the application, the CSS page isn't being located. When I view the page source, the href is <code>/MyApplication/styles/main.css</code>. Looking inside the WAR, there is a <code>/styles/main.css</code>. However, I get a 404 when I try to access the CSS file directly in the browser.</p>
  
  <p>I discovered that the reason for the issue was the Dispatcher Servlet mapping. The mapping looks as follows.</p>
  
  <pre><code>&lt;servlet-mapping&gt;
      &lt;servlet-name&gt;Spring MVC Dispatcher Servlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I imagine the Dispatcher Servlet doesn't know how to handle the CSS request. What is the best way to handle this issue? I would rather not have to change all of my request mappings. </p>