Dumb Fella Dumb Fella - 5 months ago 14
Javascript Question

Unable to load js in spring mvc

Unable to load js

JSP file

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
...
<spring:url value="/resources/home.js" var="homeJS" />
<script src="${homeJS}"></script>


web.xml

<servlet-mapping>
<servlet-name>employee</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>


spring-servlet.xml

<mvc:resources mapping="/resources/**" location="/resources" />
<mvc:annotation-driven />


I am getting HTTP Status 404
The url that it is trying to access is http://localhost:8080/Test/resources/home.js

Answer

The problem was web.xml. Modified it to :

<servlet-mapping>
        <servlet-name>employee</servlet-name>
        <url-pattern>*.do</url-pattern>
</servlet-mapping>

Now working fine

Comments