问题
I would like to do a redirect function with playframework. So far I have this in my routes
GET /redirect com.test.redirect(redirecturl: String?="")
and my controller :
public static Result redirect(String redirecturl) {
return redirect(redirectURL);
}
This is working well but I have a problem when I pass a url containing a semicolon ";"
If I go to
http:localhost:9000/redirect?redirecturl=http://www.google.com;testaftersemicolon
It redirect me to google.com but in my log the redirecturl is only equals to "http://www.google.com" stopping after a semicolon.
Is there a way to escape it ? Or to do a custom routing inside play?
回答1:
You should be able to escape it by using a custom regular expression in the routes file. This is described in the documentation about routing. Basically something like the following should work:
GET /redirect/$url<.+> com.test.redirect(url: String?="")
来源:https://stackoverflow.com/questions/11967290/escape-semicolon-route-playframework-2-0-2