user3809938
user3809938

Reputation: 1304

No mapping found for HTTP request with URI

I am creating a simple web app.

Here is my directory structure:

enter image description here

Here is what the javascript code in the jsp looks like:

<script type="text/javascript" src="JS/jquery-1.4.2.js"></script>

This is the web.xml file:

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" >

<web-app>
  <display-name>Archetype Created Web Application</display-name>


  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

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

And lastly this is the dispatcher-servlet.xml file:

<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc-3.1.xsd
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.1.xsd">

<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:resources mapping="/js/**" location="/js/" />
<mvc:annotation-driven />
<context:component-scan base-package="com.fdm.controllers" />

<bean
    class="org.springframework.web.servlet.view.InternalResourceViewResolver">
    <property name="viewClass"
        value="org.springframework.web.servlet.view.JstlView" />
    <property name="prefix" value="/WEB-INF/views/" />
    <property name="suffix" value=".jsp" />
</bean>

I keep on getting the following error:

WARNING: No mapping found for HTTP request with URI [/SpringMVCExample/JS/jquery-1.4.2.js] in DispatcherServlet with name 'dispatcher'

I have looked at various questions regarding this but I am still not able to resolve this.

Upvotes: 0

Views: 1592

Answers (1)

Amit.rk3
Amit.rk3

Reputation: 2417

try changing <mvc:resources mapping="/js/**" location="/js/" /> to <mvc:resources mapping="/JS/**" location="/JS/" />

Upvotes: 1

Related Questions