0

I'm looking for a way to url decode a string variable on Freemarker.

For example, consider the following string: attr=hello+world%3F . Expected result: hello world?

Any simple way to get this result? somewhat like ${attr?urlDecode}? I could not find anything online.

Thanks.

Amir
  • 161
  • 2
  • 14

2 Answers2

1

As mentioned above, FreeMarker only has built in support for URL encoding, not decoding. You can however solve this by creating your own directive for URI-decoding.

Something like this: https://gist.github.com/lazee/285d206470fb6076d262

Here is a small test class that shows you how you can add the directive as a shared variable, and how to use it in a template: https://gist.github.com/lazee/f5c524b3c7bebf68955e

0

There's no such function built in (2.3.23).

In what scenario is it needed?

ddekany
  • 27,645
  • 3
  • 53
  • 60