Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get hostname in freemarker template?

I have SpringMVC project with Freemarker as view resolver. In some templates I have to generate links including hostname, but I can't get it. In JSP I may to do like this:

`<% String hostName=request.getServerName();%>`

I tried to use "requestContextAttribute", but requestContext.getContextPath() returned path without hostname. Where can I get full path or hostname separately?

like image 277
just-boris Avatar asked Nov 04 '22 03:11

just-boris


1 Answers

We can do this in JSTL. Try adapting it in FreeMarker:

${pageContext.request.serverName}
like image 74
adarshr Avatar answered Nov 09 '22 10:11

adarshr