Spring boot docs suggest that velocity templates have support for ResourceUrlEncodingFilter
for rewriting static assets url with versioning. Quote from the docs:
Links to resources are rewritten at runtime in template, thanks to a ResourceUrlEncodingFilter, auto-configured for Thymeleaf, Velocity and FreeMarker.
I found out from this blog the syntax for thymeleaf for url rewriting. But after spending a couple of hours of google searching I wasn't able to find the syntax or macros for Velocity templating language. Can anyone point me to a resource which explains this.
This is a bug, see SPR-14027 . In the meantime, you can define your own macro like this:
#macro( springResourceUrl $relativeUrl )$springMacroRequestContext.getContextUrl(${relativeUrl})#end
And call it like this:
<script src="#springResourceUrl("/script.js")"></script>
Note that Velocity support is deprecated as of Spring 4.3 (see SPR-13235 ) and should be removed in Spring 5.0 (see SPR-13795 ).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.