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

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

Comments

Projects
None yet
2 participants
@spring-issuemaster
Copy link
Collaborator

commented Oct 11, 2014

Titi Wangsa opened SPR-12323 and commented

In Play Framework,
we could use this

<link rel='stylesheet' href='@routes.WebJarAssets.at(WebJarAssets.locate("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'>

and
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: http://www.webjars.org/documentation

Referenced from: commits 57e0c78, 9e5a33c, e72b821

1 votes, 8 watchers

@spring-issuemaster

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?

@spring-issuemaster

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="http://www.webjars.org/tags" prefix="wj" %>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
...
        <wj:locate path="bootstrap.min.css" var="bootstrap_css"/>
        <link rel="stylesheet" href="<spring:url value='/webjars${bootstrap_css}' />" />
...
@spring-issuemaster

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:

<dependency>
    <groupId>org.webjars</groupId>
    <artifactId>webjars-locator</artifactId>
    <version>0.22</version>
</dependency>
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.