【发布时间】:2012-07-30 09:17:14
【问题描述】:
我遇到了下一个问题:我创建了 spring 项目,向其中添加了脚本、样式和字体,映射了资源,但没有连接字体。这是萤火虫控制台:
"NetworkError: 404 Not Found - http://localhost:8080/myApp/resources/fonts/cabin-regular.woff"
"NetworkError: 404 Not Found - http://localhost:8080/myApp/resources/fonts/cabin-regular.ttf"
图像等已正确加载,所以我不去哪里寻找问题。 这是我的 css 文件的一部分,我在其中连接字体:
@import url(reset.css);
a{
text-decoration: none;
font-family: Cabin-Regular, sans-serif;
color: #472c7f;
}
a:hover{
}
@font-face {
font-family: 'Cabin-Regular';
src: url('../fonts/cabin-regular.eot');
src: url('../fonts/cabin-regular.eot?#iefix') format('embedded-opentype'),
url('../fonts/cabin-regular.woff') format('woff'),
url('../fonts/cabin-regular.ttf') format('truetype'),
url('../fonts/cabin-regular.svg#cabin-regular') format('svg');
font-weight: normal;
font-style: normal;
}
如果需要,我也可以提供上下文。 我会对任何建议或答案感到满意。 谢谢!
更新:
文件结构如下:
/resources
/fonts
/styles
/images
等等
【问题讨论】:
-
如果是 Windows 机器,可能是区分大小写/不区分大小写不匹配 - 尝试将这些文件重命名为完全不同的名称以排除这种情况。
-
@axtavt 我应该只是重命名这些文件或重命名两个文件及其扩展名(从而使窗口看不到它们)??
-
先做简单的事。您的 CSS 目录是否与 FONTS 目录在您的目录结构中确定位于同一级别?
-
@BillyMoat 查看问题更新
-
如果你把它放到你的浏览器中,它会找到文件吗? localhost:8080/myApp/resources/styles/reset.css
标签: css spring fonts stylesheet font-face