View Full Version : Access request context path from velocity/freemarker
pburleson
Nov 27th, 2004, 06:30 PM
I am trying to figure out how to make the context path of the current request available to the model for Velocity/Freemarker using SpringMVC. I need this to make absolute URLs work when needed. Is there a way to expose this easily to all my views?
Thanks,
Patrick
davison
Nov 27th, 2004, 08:17 PM
put the RequestContext into the model by setting the bean property 'requestContextAttribute' on your view (or view resolver for Velocity/FreeMarkerViewResolver). For example, in views.properties or equiv.
foo.requestContextAttribute=rc
then in your template,
${rc.contextPath}
Regards,
pburleson
Nov 27th, 2004, 11:48 PM
Thanks. I had seen that parameter before and had wondered if that was what I needed to set. Thanks for the clarification. I just tried it and like magic it worked.
Patrick
vBulletin® v3.7.3, Copyright ©2000-2008, Jelsoft Enterprises Ltd.