好吧,完整的错误是警告:在 DispatcherServlet 中找不到带有 URI [/sequenziatore/$%7BpageContext.request.contextPath%7D/resources/js/libs/require.js] 的 HTTP 请求映射,名称为“ Spring '
当我在 tomcat7 服务器上启动 Web 应用程序时,它在正确的页面 index.jsp 上打开,但它不会加载脚本 require.js...我环顾四周寻找其他帖子,发现添加 ${pageContext .request.contextPath} 请求 require.js 并添加到 spring-servlet.xml 时
但它给了我这个错误,我还将所有 css 和 js 移到了一个名为 resources 的文件夹中,但什么都没有...没有 ${pageContext.request.contextPath} 它给了我同样的错误..
web.xml:
<?xml version="1.0" encoding="ISO-8859-1"?>
<!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>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>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
</web-app>
还有 spring-servlet.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc
http://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<context:component-scan base-package="com.presenter"/>
<mvc:resources mapping="/resources/**" location="/resources/" />
<mvc:annotation-driven />
</beans>
和index.jsp:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title></title>
<link rel="stylesheet" href="resources/css/screen.css">
<link rel="stylesheet" href="resources/css/jquery.mobile-1.4.2.min.css">
<script data-main="js/main" src="${pageContext.request.contextPath}/resources/js/libs/require.js"></script>
</head>
<body>
<div data-role="page" id="home"></div>
<div data-role="page" id="page2"></div>
</body>
</html>
最佳答案
删除${pageContext.request.contextPath},data-main="js/main"将变为 resources/js/main
关于java - Spring 在 DispatcherServlet 中未找到带有 URI[require.js] 的 HTTP 请求的映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23932718/