带SiteMesh的Spring MVC控制器

带SiteMesh的Spring MVC控制器,spring,spring-mvc,sitemesh,Spring,Spring Mvc,Sitemesh,我有一个使用sitemesh和SpringMVC的应用程序,但是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 na

我有一个使用sitemesh和SpringMVC的应用程序,但是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>

网站
上下文配置位置
/WEB-INF/spring/applicationContext.xml
SiteMesh_过滤器
SiteMesh_过滤器
com.opensymphony.module.sitemesh.filter.PageFilter
SiteMesh_过滤器
/*
Spring\u上下文\u加载程序\u侦听器
org.springframework.web.context.ContextLoaderListener
Spring\u Dispatcher\u Servlet
春天
org.springframework.web.servlet.DispatcherServlet
1.
春天
/
index.jsp
我的装饰器布局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

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'
怎么了


请帮忙

尝试在上下文xml中添加以下标记。这将指定包含静态资源的目录。根据您的需要更改位置

<mvc:resources location="/resources/" mapping="/resources/**" />


阅读了解更多信息。

您应该检查两件事:1)Sitemash是否拦截CSS文件(我认为不应该),2)Spring是否允许访问CSS文件(当Sitemash未拦截它/被禁用时)。第2点)的意思是:检查静态资源处理程序映射的内容。我已经添加了静态资源处理程序映射,但它仍然没有按预期工作。如何检查Sitemesh是否拦截CSS或脚本文件?完全禁用sitemash筛选器,如果您可以访问CSS(direlty),这是sitemash配置的问题。我完全禁用sitemash筛选器,并将其放在主页面中,确保CSS也未应用。请帮助。我的css位于WebContent/css,脚本位于WebContent/script尝试:我完全禁用sitemash过滤器,并将其放在主页中,确保css也不应用。请帮忙。