Reputation: 159
I've done a sample web application recently using spring boot and groovy templates. I didn't find a simple way to provide my templates with servlet context path to get static resources urls right. Is there a way to do it? A more general way than inject request or servletcontext into controller methods? One thing i can think of is custom model attribute, but i think it's a hack rather than good solution to the problem.
Upvotes: 2
Views: 839
Reputation: 159
In groovy templates a RequestContext object is available as a parameter with name 'spring'. So all I had to do in view is
spring.getContextUrl('/link/to/some/resource')
Upvotes: 3