WebJars integration¶
WebJars integration allows Java web applications to serve client-side libraries such as CSS and JavaScript resources directly from JAR dependencies.^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md]
Resource Mapping¶
In the [[Spring MVC|Spring]] framework, specifically within the WebMvcAutoConfiguration class, a resource handler is automatically registered to map URL patterns to WebJars assets.^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md] The configuration ensures that requests matching the URL pattern /webjars/** are served from the classpath location classpath:/META-INF/resources/webjars/.^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md]
This setup integrates WebJars with the same caching configurations used for other static resources, allowing CacheControl and cache periods to be applied uniformly.^[600-developer-java-spring-thymeleaf-spring-thymeleaf-01.md]
Sources¶
Related Concepts¶
- [[Static resources]]
- [[Spring MVC]]
- [[Thymeleaf]]