sps / mustache-spring-view

java spring framework mvc view for Mustache.js templates
68 stars 31 forks source link

How to include static files in pages #8

Closed jeromevdl closed 11 years ago

jeromevdl commented 11 years ago

When using spring or jstl, we can have static resources, for exemple :

<link rel="stylesheet" href="<spring:url value="/resources/css/style.css"/>" type="text/css" />

Thus, I can include a css or js static file with the correct context path.

How to do this with this resolver. I was thinking of chaining resolvers but the "standard" InternalResourceViewResolver is an ending resolver, means i can't chain it with this one after...

Thanks

smokku commented 11 years ago

I'm using the following setup:

<bean class="org.springframework.web.servlet.view.mustache.MustacheViewResolver" id="viewResolver">
    [...]
    <property name="requestContextAttribute" value="rc"/>
</bean>

And then in the view:

href="{{rc.contextPath}}/css/style.css"
jeromevdl commented 11 years ago

Thanks, that works !