I am working with spring 3 framework for developing my web application. I have to link my external javascript file with my jsp forms. For this i am using script tag as follows:
<script type="text/javascript" src="test.js"></script>
My web.xml mapping is as follows:
`<servlet>
<servlet-name>spring</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>spring</servlet-name>
<url-pattern>*.js</url-pattern>
</servlet-mapping>`
But i am getting error like this:
Mar 13, 2014 4:54:01 PM org.springframework.web.servlet.DispatcherServlet noHandlerFound WARNING: No mapping found for HTTP request with URI [/Project/test.js] in >DispatcherServlet with name 'spring'
Here is my workspace structure. Project>>WebContent>>jsp
And in the jsp folder, i am having all the jsp's and test.js file.
I had tried - changing the web.xml configuration - tried getting context path with test.js
<script type="text/javascript" src="${pageContext.servletContext.contextPath}/test.js"></script>
- tried pasting the test.js file in different paths
created a directory inside webcontent and pasted test.js file to check
<script type="text/javascript" src="${pageContext.servletContext.contextPath}/jsp/test.js"></script>
I have referred many of related post, but i could not resolve it till now. Please somebody who had same issue help to resolve this.
EDIT Here i am adding my spring-servlet.xml for reference.
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<context:annotation-config />
<context:component-scan base-package="com.inet.test.spring3.controller" />
<bean id="jspViewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass"
value="org.springframework.web.servlet.view.JstlView" />
<property name="prefix" value="/jsp/" />
<property name="suffix" value=".jsp" />
</bean>