【发布时间】:2018-07-13 17:11:54
【问题描述】:
我在 springboot 中使用 thymeleaf,我在本地 url 中提到的所有链接都不起作用。我什至检查了浏览器上的网络选项卡,所有 css 和 js 资源都正确加载,但不知何故没有效果。这是一些代码:
<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head th:fragment="common-header">
<title>Fullstack app skeleton</title>
<!-- Bootstrap core CSS -->
<link th:href="@{/webjars/bootstrap/3.3.6/css/bootstrap.min.css}"
rel="stylesheet"></link>
<!-- Custom styles for this template -->
<link type="text/css" th:href="@{/css/styles.css}" rel="stylesheet">
</link>
</head>
<div th:fragment="before-body-scripts">
<script th:src="@{/webjars/jquery/2.1.4/jquery.min.js}"></script>
<script th:src="@{/webjars/bootstrap/3.3.6/js/bootstrap.min.js}">
</script>
<script th:src="@{/js/fullstackapp.js}"></script>
</div>
</html>
另外,我检查了 pom.xml 并且所有依赖项都已正确加载。在上面的代码中,当我提到绝对 url (https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css) 时,所有引导功能都可以工作,但是当我使用对本地 jar 的引用时,它不会。有人可以提出一个可能的原因吗???
【问题讨论】:
-
你能发布你的控制器代码来获取这个模板和你的
pom.xml吗? -
嘿,谢谢你指出,结果不知何故,请求映射中的 url 被删除了..现在一切都解决了......我的错。
标签: spring spring-boot thymeleaf