Re: url encoding of java string in freemarker template file

Posted by Deepak Dixit-3 on
URL: http://ofbiz.116.s1.nabble.com/url-encoding-of-java-string-in-freemarker-template-file-tp4708874p4708877.html

You can refer UtilCodec class

requestUrl = UtilCodec.getDecoder("url").encode(requestUrl);

requestUrl = UtilCodec.getDecoder("url").decode(requestUrl);


Thanks & Regards
--
Deepak Dixit
www.hotwaxsystems.com
www.hotwax.co

On Wed, Jul 26, 2017 at 10:40 AM, Taher Alkhateeb <
[hidden email]> wrote:

> I'm not sure there is a problem? FreeMarker is doing exactly what
> you're telling it to do by escaping any URL characters. This behavior
> is well documented [1]
>
> So I guess the question is, why and in what context are you using the
> url() built-in for.
>
> [1] http://freemarker.org/docs/ref_builtins_string.html#ref_builtin_url
>
> On Wed, Jul 26, 2017 at 5:04 AM, Wai <[hidden email]> wrote:
> > In a freemarker template, I have the following. Of course, it can also
> come
> > from a java method.
> > <#assign
> > test=Static["java.lang.String"].format("http://example.com/page?a=1&b=2")
> >
> > <p>result1=${test}</p>
> > <p>result2=${test?url('utf-8')}</p>
> >
> > The output to the webbrowser shows...
> > result1=http://example.com/page?a=1&b=2
> > result2=http%26%23x3a%3B%26%23x2f%3B%26%23x2f%3Bexample.
> com%26%23x2f%3Bpage%26%23x3f%3Ba%26%23x3d%3B1%26amp%3Bb%26%23x3d%3B2
> >
> > I'm interesting in the following correct output...
> > result1=http://example.com/page?a=1&b=2
> > result2=http%3A%2F%2Fexample.com%2Fpage%3Fa%3D1%26b%3D2
> >
> >
> > Could someone tell me what is the problem and how to solve it.
> > Thanks in advance.
> >
> >
> >
> >
> > --
> > View this message in context: http://ofbiz.135035.n4.nabble.
> com/url-encoding-of-java-string-in-freemarker-template-file-tp4708874.html
> > Sent from the OFBiz - User mailing list archive at Nabble.com.
>