How to get the Current URL in the velocity file

UdayK
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2013

Hi

I'm using a macro where i need to have Current URL.

How to get hte current URL in the velocity file. It would be good if get it with out usign javacript/jquery.

1 answer

1 accepted

6 votes
Answer accepted
UdayK
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 25, 2013

Using $req.getRequetURI will provide the current URL with out any query String parameters.

If we need query String parameters too, we have to use $req.getQueryString() method to written the query string too.

So using $req.getRequestURI and $req.getQueryString() will give us the current URL.

Alternatively,We can also get the current URL using the javascript methods.

Mamikon Papikyan October 12, 2020

 Hi @UdayK I can't get URI in .vm file. How can i include or define class for $req? 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events