Webjars is a jar package that packages these generic web front-end resources into Java, and then manages them with MAVEN tools to ensure that these Web resource versions are unique and easy to upgrade. About Webjars Resources, there is a dedicated website http://www.webjars.org/, we can go to this site to find their own resources, in their own projects to add to Maven dependency, you can directly use these resources
1. Use
Add dependency
<dependency> <groupId>org.webjars</groupId> <artifactid>webjars-locator</ artifactid> <version>0.1</version> </dependency> <dependency> < groupid>org.webjars</groupid> <artifactId>bootstrap</artifactId> <version> 2.1.1</version> </dependency>
2. Packaging:
<plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId> maven-war-plugin</artifactid> <version>2.2</version> <configuration> < failonmissingwebxml>false</failonmissingwebxml> </configuration> </plugin>
3. References
A. Static page:
<link rel= ' stylesheet ' href= ' webjars/bootstrap/2.1.1/css/bootstrap.min.css ' > <script type= ' text/ JavaScript ' src= ' webjars/jquery/1.8.2/jquery.min.js ' ></script> <script type= ' text/javascript ' src = ' Webjars/bootstrap/2.1.1/js/bootstrap.min.js ' ></script> <script type= ' text/javascript ' src= ' Webjars/ajax-form/2.1.3/ajax-form.js ' ></script>
b.jsp
<link rel= ' stylesheet ' href= ' <%= org.webjars.AssetLocator.getWebJarPath ("css/bootstrap.min.css")%> ' > <script type= ' text/javascript ' src= ' <%= org.webjars.AssetLocator.getWebJarPath ("jquery.min.js")%> ' ></script> <script type= ' text/javascript ' src= ' <%= org.webjars.AssetLocator.getWebJarPath ("js/ Bootstrap.min.js ")%> ' ></script> <script type= ' text/javascript ' src= ' <%= Org.webjars.AssetLocator.getWebJarPath ("Ajax-form.js")%> ' ></script>
Webjars CSS JS resource file Management