Mircea M
Mircea M

Reputation: 520

How to get the current URL in a Confluence Macro?

I am using Confluence and I am trying to build a User Macro (using Velocity). I would need a way to obtain the current page URL and use it as a variable. I need the whole URL (ex: http://confluence.idi.local/display/~mircea/Testing+Macros). Is there a way to achieve this? Been looking for 2 days now and I couldn't find anything...

Thank you

Upvotes: 2

Views: 2288

Answers (2)

ppasler
ppasler

Reputation: 3719

If you not just want the configured base url, you can also use the HttpServletRequest in the execute method, as described here: How do I get hold of the HttpServletRequest?

Upvotes: 0

Mircea M
Mircea M

Reputation: 520

Found it:

$action.getGlobalSettings().getBaseUrl()$content.getUrlPath()

This will display the complete URL of the page where the macro is executed.

Upvotes: 3

Related Questions