Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ability to use webjar with spring without specifying version info in HTML/jsp file [SPR-12323] #16928

spring-issuemaster opened this issue Oct 11, 2014 · 3 comments


None yet
2 participants
Copy link

commented Oct 11, 2014

Titi Wangsa opened SPR-12323 and commented

In Play Framework,
we could use this

<link rel='stylesheet' href='"css/bootstrap.min.css"))'>

we already specified the version information in the sbt file.

In Spring
We need the version information in;

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

also in the pom.xml file

Expected behaviour:
we only specify

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

Perhaps we can specify the ResourceLoader here:

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

Reference URL:

Referenced from: commits 57e0c78, 9e5a33c, e72b821

1 votes, 8 watchers


This comment has been minimized.

Copy link
Collaborator Author

commented Oct 13, 2014

Rossen Stoyanchev commented

This looks like a good candidate for a ResourceResolver (see reference update in 4.1).

Brian Clozel perhaps that's something we can add as well. A resolver to simplify access to webjars resources, perhaps triggered by prefix?


This comment has been minimized.

Copy link
Collaborator Author

commented Dec 15, 2014

Ruben Suarez Alvarez commented

As a workaround, you can use webjars-taglig-0.2.jar and, in your jsp, something like these:

<%@ taglib uri="" prefix="wj" %>
<%@ taglib prefix="spring" uri=""%>
        <wj:locate path="bootstrap.min.css" var="bootstrap_css"/>
        <link rel="stylesheet" href="<spring:url value='/webjars${bootstrap_css}' />" />

This comment has been minimized.

Copy link
Collaborator Author

commented May 19, 2015

Brian Clozel commented

This issue is now solved.
A new WebJarsResourceResolver has been implemented and searches for resources
located in WebJar locations. This ResourceResolver is automatically
registered if the "org.webjars:webjars-locator" dependency is present - this dependency is required and can be added like this:

compile 'org.webjars:webjars-locator:0.22'

Note that version 0.20+ is strongly advised, as previous versions don't support fat jars.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.