Note that there are some explanatory texts on larger screens.

plurals
  1. POSpring 3.1- javascript file not found- 404 error
    primarykey
    data
    text
    <p>I have a js file in the folder WebContent/resources/js/test.js. I am trying to include the same file in a jsp. But the jsp file is unable to find the js file (404 error in browser console). I have gone throw couple of questions in SO:</p> <p><a href="https://stackoverflow.com/questions/1234298/can-springmvc-be-configured-to-process-all-requests-but-exclude-static-content">Can SpringMVC be configured to process all requests, but exclude static content directories?</a></p> <p><a href="https://stackoverflow.com/questions/3655316/browser-cant-access-css-and-images-when-calling-a-servlet-which-forwards-to-a-j">Browser can&#39;t access/find relative resources like CSS, images and links when calling a Servlet which forwards to a JSP</a></p> <p><a href="https://stackoverflow.com/questions/7941880/sts-spring-mvc-how-to-include-a-js-file-in-a-jsp">STS Spring MVC: How to include a JS file in a JSP</a></p> <p>But still not helping. Here goes my code:</p> <p>In the application context, i am using the mvc:resource tag.</p> <pre><code>&lt;mvc:resources mapping="/resources/**" location="/resources/" /&gt; </code></pre> <p>In my jsp</p> <pre><code>&lt;script src="${contextPath}/resources/js/test.js" type="text/javascript"&gt;&lt;/script&gt; </code></pre> <p>tried giving src value with </p> <pre><code> &lt;c:url&gt; </code></pre> <p>too.</p> <p>my web.xml has</p> <pre><code>&lt;servlet-mapping&gt; &lt;servlet-name&gt;TestProject&lt;/servlet-name&gt; &lt;url-pattern&gt;/&lt;/url-pattern&gt; &lt;/servlet-mapping&gt; </code></pre> <p>Firebug says </p> <pre><code>The requested resource (/resources/js/test.js) is not available. </code></pre> <p>Any help would be appreciated.</p> <p><strong>UPDATE</strong></p> <p>The GET request URL in firebug is this</p> <pre><code>http://localhost:8080/TestProject/resources/js/test.js </code></pre> <p>Is it right??</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload