【发布时间】:2022-02-07 00:48:29
【问题描述】:
我使用此解决方案将一个百里香叶包含在另一个中。它解决了我的问题,但现在根本不加载 css 文件
Thymeleaf: Replace div with other pages on controllers
这是我的控制器:
@GetMapping("/allUsers")
public String userList(Model theModel) {
List<User> theUsers = userService.findAll();
theModel.addAttribute("users", theUsers);
return "dashboard :: setFragment(content_fragment='/admin/allUsers')";
}
以及链接到css文件的html部分
<link rel="stylesheet" type="text/css" href="/css/style.css">
<script>
$(function () {
var includes = $('[data-include]');
$.each(includes, function () {
var file = '/admin' + $(this).data('include') + '.html';
$(this).load(file);
});
});
</script>
<title>Dashboard</title>
</head>
<body>
<div th:insert="fragments/header :: header"></div>
<div class="row">
<div id="content" th:fragment="setFragment(content_fragment)">
<div th:insert="fragments/dashboard :: aside" class="col-md-2 px-3"></div>
<div th:insert="fragments/users :: users" class="col-md-10 py-3"></div>
</div>
</div>
</body>
...
【问题讨论】:
标签: html spring spring-boot spring-mvc thymeleaf