没有找到带有URI的HTTP请求的映射

时间:2015-06-23 19:31:58

标签: java jquery jsp spring-mvc

我正在创建一个简单的网络应用。

这是我的目录结构:

enter image description here

以下是jsp中的javascript代码:

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

这是web.xml文件:

<!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>

最后这是dispatcher-servlet.xml文件:

<?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>

我一直收到以下错误:

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

我已经查看过有关此问题的各种问题,但我仍然无法解决此问题。

1 个答案:

答案 0 :(得分:1)

尝试将<mvc:resources mapping="/js/**" location="/js/" />更改为<mvc:resources mapping="/JS/**" location="/JS/" />