2012-02-24 46 views
0

我有一個運行在Tomcat 7.0上的基於Spring MVC的Web應用程序。我們也在應用程序中使用Tiles框架。未在我的彈簧MVC應用程序中加載CSS文件

下面是我的佈局頁面的代碼。在頁面中我包含了一些CSS文件和JavaScript文件。

<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 

<%@ page contentType="text/html; charset=utf-8" language="java"%> 
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%> 
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%> 
<%@ taglib uri="http://www.springframework.org/tags" prefix="spring"%> 

<html> 
    <head> 
     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> 
     <title>Application</title> 

     <!-- CSS Files --> 
     <link type="text/css" href="<c:url value='/resources/css/themes/base/jquery.ui.all.css'/>"> 
     <link type="text/css" href="<c:url value='/resources/css/styles.css'/>" /> 

     <!-- Javascript Files -->  
     <script src="<c:url value='/resources/scripts/jquery/jquery-1.7.1.js'/>"></script> 
     <script src="<c:url value='/resources/scripts/jquery/ui/jquery.ui.core.js'/>"></script> 
     <script src="<c:url value='/resources/scripts/jquery/ui/jquery.ui.widget.js'/>"></script> 
     <script src="<c:url value='/resources/scripts/jquery/ui/jquery.ui.button.js'/>"></script> 
     <script src="<c:url value='/resources/scripts/common.js'/>"></script> 

     <script> 
      $(function() { 
       $("input:submit, a, input:button", ".buttonDiv").button(); 
       $("a", ".buttonDiv").click(function() { 
        return false; 
       }); 

      }); 
     </script> 
    </head> 
    <body> 
     <div id="container"> 
      <div id="header"> 
       <tiles:insertAttribute name="header"> 
        <tiles:putAttribute name="menu" 
         value="/WEB-INF/jsps/common/menu.jsp" /> 
       </tiles:insertAttribute> 
      </div> 
      <div id="body"> 
       <tiles:insertAttribute name="body" /> 
      </div> 
      <div id="footer"> 
       <tiles:insertAttribute name="footer" /> 
      </div> 
     </div> 
    </body> 
</html> 

Javascript文件被正確加載,但不是CSS文件。

此外,我在mY彈簧配置文件中有folowowing代碼。

<!-- Handles HTTP GET requests for /resources/** by efficiently serving 
    up static resources in the ${webappRoot}/resources/ directory --> 
<mvc:resources location="/resources/" mapping="/resources/**" /> 

我正在使用IE7瀏覽器。我沒有任何其他瀏覽器需要測試。

我包括我的CSS文件的方式有什麼問題嗎?

請幫忙。

回答

0

嘗試這種添加CSS文件

<link href="../../Content/Site.css" rel="stylesheet" type="text/css" /> 
0

將同時給予CSS,IMG或腳本文件的JSP參考以下行

<link href="${pageContext.request.contextPath}/resources/css/xxxx" 
    rel="stylesheet"> //xxxx is the resources 
<link href="${pageContext.request.contextPath}/resources/css/jquery-ui.css" rel="stylesheet"> 
相關問題