Skip to main content
Skip table of contents

How to encode URL parameters in a PocketQuery Velocity Template

Say you want to build a URL out of your results, but they might contain characters that you need to escape. In this case you can use the urlEncode() method provided by the GeneralUtils object like this:

CODE
#set($param = $generalUtil.urlEncode("b:a/r"))
#set($url = "./viewpage.action?pageId=12345678&foo=${param}&ping=pong")

The result will be a correctly encoded URL:

CODE
./viewpage.action?pageId=12345678&foo=b%3Aa%2Fr&ping=pong

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.