我对 Thymeleaf 和 SpringBoot 还是有点陌生。
我一直在尝试使用百里香片段将带有所有javascript映射的块注入页面-dashboardAdmin.html。
我已经能够使用传统的片段正确地注入带有块的片段,但是由于我必须注入多个不在 html 模板中的任何标签内的脚本标签,所以我无法使用传统的方法。
我在这里发现了一个类似的问题 ,并遵循了提供的具体解决方案,但仍然没有成功,我已经添加了依赖项。也许有某种我不知道的语法错误。由于我在这方面找不到太多参考资料,任何人都可以在这方面给我建议吗?
这是包含要插入其他页面的所有模板的fragment.html
<body>
<th:block layout:fragment="script">
<script th:src="@{/vendor/login_v14/vendor/jquery/jquery-3.2.1.min.js}"></script>
<!-- Bootstrap 4 -->
<script th:src="@{/vendor/bootstrap/js/bootstrap.bundle.min.js}"></script>
<!-- jsGrid -->
<script th:src="@{/vendor/jsgrid/demos/db.js}"></script>
<script th:src="@{/vendor/jsgrid/jsgrid.min.js}"></script>
<!-- AdminLTE App -->
<script th:src="@{/js/main.js}"></script>
</th:block>
</body>
虽然这是我将块注入到的页面模板-dashboardAdmin.html
<!DOCTYPE html>
<html lang="fr" xmlns:th="http://www.w3.org/1999/xhtml" xmlns="http://www.w3.org/1999/html"
xmlns:layout="http://www.w3.org/1999/xhtml"
layout:decorate="~{fragments/fragments}">
<head th:replace="fragments/fragments :: head">
</head>
<body class="hold-transition sidebar-mini">
<!--js scripts-->
<th:block layout:fragment="script">
</th:block>
</body>
如果有人能告诉我我在这里做错了什么,将不胜感激:D!