Mage
Mage

Reputation: 159

Spring Boot and context path

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

Answers (1)

Mage
Mage

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

Related Questions