bootstrap和jquery的maven依赖(亲测可用)

曾经用过,记录一下

pom.xml

       <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>webjars-locator</artifactId>
            <version>0.45</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>3.3.7</version>
        </dependency>

        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>3.6.0</version>
        </dependency>

jsp内引用

  <script src="${pageContext.request.contextPath}/webjars/jquery/3.6.0/jquery.min.js"></script>
    <script src="${pageContext.request.contextPath}/webjars/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/webjars/bootstrap/3.3.7/css/bootstrap.min.css" />

用springMvc的记得要在springMvc.xml里放行,不然会被拦截(/webjars/变红是正常的,因为项目没运行时这里没有这个文件夹)

   <mvc:resources mapping="/webjars/**" location="/webjars/" />

html内引用(有thymeleaf情况下)

  <script type="text/javascript" th:src="@{/webjars/jquery/3.6.0/jquery.min.js}"></script>
    <script type="text/javascript" th:src="@{/webjars/bootstrap/3.3.7/js/bootstrap.min.js}"></script>
    <link rel="stylesheet" th:href="@{/webjars/bootstrap/3.3.7/css/bootstrap.min.css}" />

没有thymeleaf的话直接./或../即可,webjars路径位置可以在网页控制台的Sources里看到

 

 所以我这里用的是../

    <script src="../webjars/jquery/3.6.0/jquery.min.js"></script>
    <script src="../webjars/bootstrap/3.3.7/js/bootstrap.min.js"></script>
    <link rel="stylesheet" href="../webjars/bootstrap/3.3.7/css/bootstrap.min.css"/>

最后还有个bootstrapValidator的依赖,引用方式应该差不多,但没有测试过(因为后面就没用这个做验证了)

    <dependency>
      <groupId>org.webjars.bower</groupId>
      <artifactId>bootstrapValidator</artifactId>
      <version>0.5.2</version>
    </dependency>

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值