【发布时间】:2017-04-01 19:47:47
【问题描述】:
我的目录结构是
目录结构
src/
main/
resources/
static/
CSS/
JS/
images/
template/
fragments/
header.html
footer.html
navBar.html
layouts/
appLayout.html
baseLayout.html
welcome.html
appLayout.html
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org"
xmlns:layout="http://www.ultraq.net.nz/thymeleaf/layout">
<head>
<link rel="stylesheet" type="text/css" media="screen, projection"
href="/static/css/bootstrap.css"
th:href="@{/bootstrap.min.css}" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="/static/css/bootstrap.css"
th:href="@{/css/bootstrap.min.css}" />
<link rel="stylesheet" type="text/css" media="screen, projection"
href="/static/css/bootstrap.css"
th:href="@{css/bootstrap.min.css}" />
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.0/css/bootstrap.min.css"
th:href="@{/webjars/bootstrap/2.3.0/css/bootstrap.min.css}" rel="stylesheet" />
</head>
<body>
<div th:replace="/fragments/header :: header"></div>
<div th:replace="/fragments/navbar :: navbar"></div>
<div class="container">
<div layout:fragment="content">
<p>Content goes here...</p>
</div>
<footer>
<div th:replace="/fragments/footer :: footer"></div>
</footer>
</div>
</body>
</html>
请检查上面布局中的<links>标签,我使用了不同的位置链接标签,没有给出404 error为什么会这样?
请看上图,我在 resources/static/css/ 文件夹中有 css 和 js 文件,而 JS 是 int /resources/static/js/ 文件夹这是怎么回事?为什么chrome对某些静态资源不显示404错误?
【问题讨论】:
-
你能举一个你认为会出错的具体例子吗?
-
bootstrap.min.css位于static/css/中,因此其他链接资源应在 chrome devtool 上显示 404 错误。 -
您是否添加了自定义资源处理程序?
-
没有。我使用的是spring boot的默认设置
-
您是否通过控制器映射了welcome.html?如果不添加控制器来映射您的 HTML 页面的 URL
标签: spring-boot thymeleaf