title: JavaScript with Spring MVC doesn't work
body: <p>I downloaded login template which uses css and JavaScript. When I start it in default html format it displays ok, but when I put the same code to my Spring MVC 3 app and change format to jsp, javascript part is disabled. I can access external js files through my web browser, so I don't know where may be the problem.</p>
  
  <p>This is the right look:
  <img src="https://i.stack.imgur.com/l94Le.jpg" alt="right"></p>
  
  <p>but this is what i get:
  <img src="https://i.stack.imgur.com/RNTSg.png" alt="wrong"></p>
  
  <pre><code>&lt;script language="javascript" type="text/javascript" src="js/niceforms.js"&gt;&lt;/script&gt;
  &lt;link rel="stylesheet" type="text/css" media="all" href="css/niceforms-default.css" /&gt;
  </code></pre>
  
  <p>I only changed the location of external js and css resources but these files are accessable as I said.</p>
  
  <p>This is my structure:</p>
  
  <p><img src="https://i.stack.imgur.com/uKETE.png" alt="enter image description here"></p>
  
  <p>In my <code>web.xml</code> I have these lines:</p>
  
  <pre><code>&lt;!-- The definition of the Root Spring Container shared by all Servlets and Filters --&gt;
  &lt;context-param&gt;
      &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
      &lt;param-value&gt;
          /WEB-INF/spring/root-context.xml,
          /WEB-INF/spring/security-context.xml,
      &lt;/param-value&gt;
  &lt;/context-param&gt;
  
  &lt;!-- Creates the Spring Container shared by all Servlets and Filters --&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  
  &lt;!-- Processes application requests --&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
      &lt;init-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/spring/appServlet/servlet-context.xml&lt;/param-value&gt;
      &lt;/init-param&gt;
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;appServlet&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;!-- Spring Security --&gt;
  &lt;filter&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;filter-class&gt;org.springframework.web.filter.DelegatingFilterProxy&lt;/filter-class&gt;
  &lt;/filter&gt;
  
  &lt;filter-mapping&gt;
      &lt;filter-name&gt;springSecurityFilterChain&lt;/filter-name&gt;
      &lt;url-pattern&gt;/*&lt;/url-pattern&gt;
  &lt;/filter-mapping&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.css&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.js&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.gif&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.jpg&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.png&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;default&lt;/servlet-name&gt;
      &lt;url-pattern&gt;*.txt&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  </code></pre>
  
  <p>I also use Apache tiles2</p>
  
  <pre><code>&lt;tiles-definitions&gt;
  &lt;definition name="base.definition" template="/WEB-INF/views/layout/layout.jsp"&gt;
      &lt;put-attribute name="body" value="" /&gt;
  &lt;/definition&gt;
  
  &lt;definition name="contact" extends="base.definition"&gt;
      &lt;put-attribute name="body" value="/WEB-INF/views/contact.jsp" /&gt;
  &lt;/definition&gt;
  
  &lt;definition name="login" template="/WEB-INF/views/login/login.jsp"&gt;
  &lt;/definition&gt;
  </code></pre>
  
  <p></p>
  
  <p>Thanks.</p>
  
  <p>Edit:</p>
  
  <p>I know where is the problem now, but still don't know how to solve it... Problem is in paths in external css files. I have something like this: <code>body {background-image:url('images/bg.jpg');}</code> but I get not found error in firebug because it tries to find the resource in <em>localhost:8080/sheedo/css/images/bg.jpg</em> and when I set absolute path of resource like <code>body {background-image:url('/images/bg.jpg');}</code> I get the same error too but it tries to find it in <em>localhost:8080/images/bg.jpg</em>. When I use <code>./images/bg.jpg</code> it's ok, but does exist any other solution instead of rewrite all paths in css files? I mean something like <code>&lt;mvc:resources ... &gt;</code> is it possible ?</p>