Excuse my ignorance but I am new to Velocity and trying to fix someone else's problem. I need to encode a URL inside the velocity template. I create a url and as part of the query string I pass in a page name a user created. This page can contain special characters like ëðû. The url would look like http://foo.com/page1/jz?page=SpecialChars_ëðû
To encode URL inside a template you can use:
$esc.url($myUrl)
which is a part of EscapeTool.
Note: This required to use velocity tools jar, in addition to the velocity jar. (It will not throw exception if you will not have it). Moreover, you might want to check you configuration, as describes here
I know it is late. Here is how I solved this today. In the class calling the engine, you could say
configure("esc",new EscapeTool());
context.put("url", "http://www.google.com");
Now in the template you could say
$esc.url($url)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With