How can I encode an URL in a template with Play 2?
I search a helper like this:
urlEncode doesn\'t work now
As I can see in linked ticked it will be resolved in Play 2.1
Quickest solution is placing ,method(s) for that in you controller (Application.java
in this sample)
public static String EncodeURL(String url) throws java.io.UnsupportedEncodingException {
url = java.net.URLEncoder.encode(url, "UTF-8");
return url;
}
public static String EncodeURL(Call call) throws java.io.UnsupportedEncodingException {
return EncodeURL(call.toString());
}
and then using it in the view as required at the moment:
Encoded url form router
Encoded url from string
Url mixed normal+encoded