Spring boot 使用 Webjars

Spring boot 使用 Webjars

https://www.webjars.org/ 介绍整合前端静态资源

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>jquery</artifactId>
    <version>3.4.1</version>
</dependency>
<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>bootstrap</artifactId>
    <version>4.4.1-1</version>
</dependency>

在springboot 项目static 目录下新建一个index.html 页面

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>deyou</title>

    <link rel="stylesheet" href="webjars/bootstrap/4.4.1-1/css/bootstrap.min.css" />
    <script src="webjars/jquery/3.4.1/jquery.min.js"></script>
    <script src="webjars/bootstrap/4.4.1-1/js/bootstrap.min.js"></script>

</head>
<body>
<div class="container"><br>
    <div class="alert alert-success">
        <a href="#" class="close" data-dismiss="alert" aria-label="close">X</a>
        Hello, <strong>De you !</strong>
    </div>

</div>
<script>
    alert($('.close').attr('herf'));
</script>
</body>
</html>

启动项目。访问

http://localhost:8080/

和 http://localhost:8080/webjars/jquery/3.4.1/jquery.min.js

发布了88 篇原创文章 · 获赞 4 · 访问量 1万+

猜你喜欢

转载自blog.csdn.net/qq_21344887/article/details/105090123