WebJars——web端静态资源打jar包

WebJars是将web前端资源(js,css等)打成jar包文件,然后借助Maven工具,以jar包形式对web前端资源进行统一依赖管理,保证这些Web资源版本唯一性。WebJars的jar包部署在Maven中央仓库上。

pom.xml:

<dependencies>
    <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>jquery</artifactId>
            <version>2.2.4</version>
        </dependency>
        <dependency>
            <groupId>org.webjars</groupId>
            <artifactId>bootstrap</artifactId>
            <version>3.3.6</version>
        </dependency>
</dependencies>

静态页面:

<link rel='stylesheet' href='webjars/bootstrap/3.3.6/css/bootstrap.min.css'>

<script type='text/javascript' src='webjars/bootstrap/3.3.6/js/bootstrap.min.js'></script>

<script type='text/javascript' src='webjars/jquery/2.2.4/jquery.min.js'></script>

JSP页面:

<link rel='stylesheet'  href="<%=request.getContextPath() %>/webjars/bootstrap/3.3.6/css/bootstrap.min.css"/>

<script type="text/javascript" src="<%=request.getContextPath() %>/webjars/bootstrap/3.3.6/js/bootstrap.min.js"></script>

<script type="text/javascript" src="<%=request.getContextPath() %>/webjars/jquery/2.2.4/jquery.min.js"></script>

猜你喜欢

转载自blog.csdn.net/fantasy522272820/article/details/80190086
今日推荐