Encoding url's the Play! Framework
Is there a way to make the Play! Framework ignore slas开发者_开发百科hes and ?
in parts of the URL?
Typically, if I have the following:
www.123.com/api/link/http:www.bla.com/?contenId=123&User=test
It won't work. In that case, what I would want to do is simply have the link in the last part of the URL in a String
variable to save it. I suppose I can force the client to replace the /
and ?
by something else, but I would rather keep it simple.
My first thought was that maybe there is a way to configure the routing such that we have something like:
/api/link/{data}
where data
would hold whatever remains of the URL. Can't find out how to do that though.
You can't have :
/
?
except your main URL. You should encode your parameter to append it to main URL. See URLEncoder for Java.
This is not a valid URL:
http://www.123.com/api/link/http://www.bla.com/?contenId=123&User=test
It must be:
http://www.123.com/api/link/http%3a%2f%2fwww.bla.com%2f%3fcontenId%3d123%26User%3dtest
Then you can pass it to {data}
parameter and decode it in your handler method.
精彩评论