【发布时间】:2018-08-15 06:40:09
【问题描述】:
我正在尝试使用 Thymeleaf 将引导程序添加到我的 Spring Boot 项目中。
index.html
<!DOCTYPE html >
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head th:replace="fragments/header :: header"> </head>
<body>
<div th:replace="@{'views/' + ${content}} :: ${content}"></div>
<div lang="en" th:replace="fragments/footer :: footer"> </div>
</body>
</html>
页脚.html
<div xmlns:th="http://www.thymeleaf.org" th:fragment="footer" >
<script th:src="@{/webjars/jquery/3.3.1/jquery.min.js}"></script>
<script th:src="@{/webjars/popper.js/1.12.9-1/umd/popper.min.js}"></script>
<script th:src="@{/webjars/bootstrap/4.0.0-1/js/bootstrap.min.js}" ></script>
</div>
header.html
<head xmlns:th="http://www.thymeleaf.org" th:fragment="header" >
<meta charset="UTF-8">
<title>Модуль планирования ПД</title>
<link th:rel="stylesheet" th:href="@{webjars/bootstrap/4.0.0-1/css/bootstrap.min.css} "/>
</head>
MvcConfig.java
@Configuration
public class MvcConfig implements WebMvcConfigurer {
@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
registry
.addResourceHandler("/webjars/**")
.addResourceLocations("/webjars/")
.resourceChain(false);
}
}
样式不适用于页面并引发错误: 在 jquery、bootstrap、popper 中。
我该如何解决这个问题?
谢谢。
【问题讨论】:
标签: spring spring-boot thymeleaf twitter-bootstrap-4 webjars