Spring - Webjar Bootstrap得到了高度评​​价

时间:2017-10-19 17:55:46

标签: java html spring twitter-bootstrap thymeleaf

在一个Spring maven项目中我有一些使用百里香和自举的html页面,它们完美地工作,直到出于任何原因/webjars/bootstrap/3.3.7-1/css/bootstrap.min.css/webjars/bootstrap/3.3.7-1/js/bootstrap.min.js曾经是正确的bootstrap.css和bootstrap.js得到了批评,现在他们是页面的副本。

index.html head

<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8"/>
    <title>Title</title>

    <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
      crossorigin="anonymous" th:href="@{/webjars/bootstrap/3.3.7-1/css/bootstrap.min.css}">
    <script src="/webjars/jquery/3.2.1/jquery.min.js"/>
    <script src="//maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
        crossorigin="anonymous" th:src="@{/webjars/bootstrap/3.3.7-1/js/bootstrap.min.js}"></script>
</head>

如果我打开页面源并单击其中任何一个链接,它们会显示html页面的副本,而不是.css和.js代码。这种情况在几个小时前没有发生过,我从未触及maven依赖关系,因此我不知道这是怎么发生的,一个简单的解决方法就是删除th:href并留下正常的href来完成工作但是我更喜欢使用本地.css和.js。这些是依赖

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>bootstrap</artifactId>
    <version>3.3.7-1</version>
</dependency>
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>jquery</artifactId>
    <version>3.2.1</version>
</dependency>

0 个答案:

没有答案