我有一个使用sitemesh和spring mvc的应用程序但是无法应用css和javascript。
15:13:38,745 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SiteMesh/css/default.css] in DispatcherServlet with name 'spring'
15:13:38,750 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-5) No mapping found for HTTP request with URI [/SiteMesh/css/jquery.jmover.css] in DispatcherServlet with name 'spring'
15:13:38,748 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-6) No mapping found for HTTP request with URI [/SiteMesh/css/jquery-updates.css] in DispatcherServlet with name 'spring'
15:13:38,748 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-3) No mapping found for HTTP request with URI [/SiteMesh/css/jquery-ui-1.7.1.custom.css] in DispatcherServlet with name 'spring'
15:13:38,745 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-2) No mapping found for HTTP request with URI [/SiteMesh/css/view.css] in DispatcherServlet with name 'spring'
15:13:38,755 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-3) No mapping found for HTTP request with URI [/SiteMesh/script/jquery.dataTables-1.7.5.min.js] in DispatcherServlet with name 'spring'
15:13:38,755 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-6) No mapping found for HTTP request with URI [/SiteMesh/css/jquery-ui.css] in DispatcherServlet with name 'spring'
15:13:38,759 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-2) No mapping found for HTTP request with URI [/SiteMesh/script/jquery.validate.js] in DispatcherServlet with name 'spring'
15:13:38,753 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-5) No mapping found for HTTP request with URI [/SiteMesh/css/menu.css] in DispatcherServlet with name 'spring'
15:13:38,750 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-4) No mapping found for HTTP request with URI [/SiteMesh/css/datatables.css] in DispatcherServlet with name 'spring'
15:13:38,750 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SiteMesh/css/confirmationStyle.css] in DispatcherServlet with name 'spring'
15:13:38,762 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-2) No mapping found for HTTP request with URI [/SiteMesh/script/jquery.autocomplete.js] in DispatcherServlet with name 'spring'
15:13:38,759 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-6) No mapping found for HTTP request with URI [/SiteMesh/script/jquery.blockUI.js] in DispatcherServlet with name 'spring'
15:13:38,764 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-5) No mapping found for HTTP request with URI [/SiteMesh/script/jquery.selectboxes.min.js] in DispatcherServlet with name 'spring'
15:13:38,757 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-3) No mapping found for HTTP request with URI [/SiteMesh/script/jquery-ui.core.js] in DispatcherServlet with name 'spring'
15:13:38,763 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SiteMesh/script/dropmenu.js] in DispatcherServlet with name 'spring'
15:13:38,763 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-4) No mapping found for HTTP request with URI [/SiteMesh/script/jquery.jmover-1.2.js] in DispatcherServlet with name 'spring'
15:13:38,843 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SiteMesh/script/jquery-ui.core.js] in DispatcherServlet with name 'spring'
15:13:38,859 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SiteMesh/script/jquery.blockUI.js] in DispatcherServlet with name 'spring'
15:13:38,879 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SiteMesh/script/jquery.autocomplete.js] in DispatcherServlet with name 'spring'
15:13:38,894 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SiteMesh/script/jquery.selectboxes.min.js] in DispatcherServlet with name 'spring'
15:13:38,900 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SiteMesh/script/jquery.jmover-1.2.js] in DispatcherServlet with name 'spring'
15:13:38,929 WARN [org.springframework.web.servlet.PageNotFound] (http-localhost-127.0.0.1-8080-1) No mapping found for HTTP request with URI [/SiteMesh/script/dropmenu.js] in DispatcherServlet with name 'spring'
我确认sitemesh工作正常,因为当我更改url模式时,sitemesh无效。
的web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app id="WebApp_ID" version="2.5"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<display-name>SiteMesh</display-name>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/spring/applicationContext.xml</param-value>
</context-param>
<filter>
<display-name>SiteMesh_Filter</display-name>
<filter-name>SiteMesh_Filter</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>SiteMesh_Filter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<listener>
<display-name>Spring_Context_Loader_Listener</display-name>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<servlet>
<display-name>Spring_Dispatcher_Servlet</display-name>
<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>
我的装饰布局JSP
<%@include file="../pages/init-page.jsp" %>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" >
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<meta name="" />
<meta name="description" content="" />
<title>
<decorator:title default="IRM - Intelligent Routing Module" />
</title>
<!-- CSS Links -->
<link rel="stylesheet" href="${context}/css/default.css" type="text/css" />
<link rel="stylesheet" href="${context}/css/view.css" type="text/css" />
<link rel="stylesheet" href="${context}/css/jquery-ui-1.7.1.custom.css" type="text/css" media="screen" />
<link rel="stylesheet" type="text/css" media="screen" href="${context}/css/datatables.css" />
<link rel="stylesheet" type="text/css" media="screen" href="${context}/css/jquery.jmover.css" />
<link rel="stylesheet" type="text/css" media="screen" href="${context}/css/jquery-updates.css"/>
<link rel="stylesheet" type="text/css" media="screen" href="${context}/css/confirmationStyle.css"/>
<link rel="stylesheet" href="${context}/css/menu.css" type="text/css" />
<link rel="stylesheet" href="${context}/css/jquery-ui.css" type="text/css" />
<!-- Scripts -->
<script type="text/javascript" src="${context}/script/jquery.dataTables-1.7.5.min.js"></script>
<script type="text/javascript" src="${context}/script/jquery.validate.js"></script>
<script type="text/javascript" src="${context}/script/jquery-ui.core.js"></script>
<script type="text/javascript" src="${context}/script/jquery.blockUI.js"></script>
<script type="text/javascript" src="${context}/script/jquery.autocomplete.js"></script>
<script type="text/javascript" src="${context}/script/jquery.selectboxes.min.js"></script>
<script type="text/javascript" src="${context}/script/jquery.jmover-1.2.js"></script>
<decorator:head/>
</head>
<body>
<%-- Header --%>
<%@include file="../pages/header.jsp" %>
<c:if test="${sessionScope.user != null}">
<%@include file="../pages/header.jsp" %>
</c:if>
<decorator:body/>
<%-- Footer --%>
<%@include file="../pages/footer.jsp" %>
</body>
</html>
似乎所有来自此jsp的脚本和css都无法应用。
它有什么问题?
请帮忙。
答案 0 :(得分:2)
尝试在上下文xml中添加以下标记。这将指定包含静态资源的目录。根据您的需要更改位置。
<mvc:resources location="/resources/" mapping="/resources/**" />
阅读this post了解详情。