static下放资源,templates下放html
所以就用了thymeleaf
若是一起放在static下的,路径上用相对路劲就可以了(路径上不一样,下面有样例)

【注意】方式二、三需要部署后才能加载使用

方式一:直接加载static下的文件

  1. 将所引用的版本下载好
  2. 引入jar包
//使用thymeleaf
<script type="text/javascript" th:src="@{/js/jquery-3.3.1.min.js}"></script>

//一起放在static下
<script type="text/javascript" src="js/jquery-3.3.1.min.js"></script>

方式二:导入jar包

<!-- jquery-->
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.5.1</version>
        </dependency>
<!--	引入jQuery-->
    <script type="text/javascript" th:src="@{/webjars/jquery/3.5.1/jquery.min.js}"></script>

在这里插入图片描述

方式三:在线引入

<script th:src="@{https://cdn.bootcdn.net/ajax/libs/jquery/3.6.0/jquery.min.js}"></script>

所有版本链接


【推荐其他整合或是引用】

Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐