【发布时间】:2013-08-02 16:35:19
【问题描述】:
我正在尝试在 spring mvc 环境下运行的 jsp 页面中应用 css 规则。 webapp/css/mystyles.css:
.center{
margin: auto; text-align: center;
}
h1{
color: red;
}
webapp/WEB-INF/jsp/Layout.jsp:
<%@ taglib prefix="tiles" uri="http://tiles.apache.org/tags-tiles" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
<title><tiles:insertAttribute name="title" ignore="true"/></title>
<link rel="stylesheet" type="text/css" href="../../css/mystyles.css" media="screen" />
</head>
<body>
<table border="1" cellspacing="2" align="center">
<tr>
<td height="30" colspan="2">
<tiles:insertAttribute name="header"/>
</td>
</tr>
<tr>
<td height="250" width="150">
<tiles:insertAttribute name="menu"/>
</td>
<td width="400">
<tiles:insertAttribute name="body"/>
</td>
</tr>
<tr>
<td height="30" colspan="2">
<tiles:insertAttribute name="footer"/>
</td>
</tr>
</table>
</body>
</html>
这是我使用 firebug 获得的网页代码的一部分:
<head>
<title>Being Java Guys | Tiles Integration</title>
<link media="screen" href="../../css/mystyles.css" type="text/css" rel="stylesheet">
<html><head><title>Apache Tomcat/7.0.35 - Error report</title><style><!--H1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}HR {color : #525D76;}--></style> </head><body><h1>HTTP Status 404 - </h1><HR size="1" noshade="noshade"><p><b>type</b> Status report</p><p><b>message</b> <u></u></p><p><b>description</b> <u>The requested resource is not available.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/7.0.35</h3></body></html>
</link>
</head>
<div class="center">
<h1>Header</h1>
</div>
很遗憾,我没有收到红色标题。
【问题讨论】:
-
浏览器是否读取css文件?
-
如何检查?
-
在浏览器的调试器下调用页面。 FireFox、Chrome 和 IE(当前版本)都有。它们在调试器中有一个标签,可以向您显示实际加载了哪些文件以及哪些文件加载失败。
-
是的。 Firebug 运行良好。我认为有一个“网络”选项卡。标签在右边,可能在最后一个。
-
我启用了网络标签,但它什么也没显示。
标签: spring spring-mvc tomcat7 tiles