gpt4 book ai didi

我的 spring MVC 应用程序中没有加载 CSS 文件

转载 作者:行者123 更新时间:2023-11-28 14:11:24 24 4
gpt4 key购买 nike

我有一个在 Tomcat 7.0 上运行的基于 spring MVC 的 Web 应用程序。我们还在应用程序中使用了 Tiles 框架。

下面是我的布局页面的代码。在页面中,我包含了一些 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 文件未正确加载。

我的 spring 配置文件中还有以下代码。

    <!-- 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 文件的方式有问题吗?

请帮忙。

最佳答案

try this to add your css file

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

关于我的 spring MVC 应用程序中没有加载 CSS 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9425873/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com