You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by sliver <sl...@gmx.at> on 2005/08/18 14:51:39 UTC
Encode url
Hi,
how do I encode a string in velocity?
I tried this
#set( $encodedStr = $link.encodeURL($string))
but it doesn't encode characters like '?' and '&'. I need them to put a URL
into a parameter of a request string.
e.g.
http://foo.bar.org/some.action?backurl=another.action?foo=bar&bar=foo
where backurl should be another.action?foo=bar&bar=foo
TIA
Stefan
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org
Re: Encode url
Posted by Nathan Bubna <nb...@gmail.com>.
yeah, the encode URL method is not meant to escape key URL characters,
but rather to encode spaces and such to be URL-friendly.
if you want to escape key URL characters like '?', you will either
need to write your own method or find a utility. you might try the
StringUtils class in commons-lang or something like that.
On 8/18/05, sliver <sl...@gmx.at> wrote:
> Hi,
>
> how do I encode a string in velocity?
>
> I tried this
>
> #set( $encodedStr = $link.encodeURL($string))
>
> but it doesn't encode characters like '?' and '&'. I need them to put a URL
> into a parameter of a request string.
>
> e.g.
> http://foo.bar.org/some.action?backurl=another.action?foo=bar&bar=foo
>
> where backurl should be another.action?foo=bar&bar=foo
>
> TIA
> Stefan
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: velocity-user-help@jakarta.apache.org