逃避分号路线playframework 2.0.2

问题描述 投票:1回答:1

我想用play框架做一个重定向功能。到目前为止,我的路线中有这个

GET     /redirect            com.test.redirect(redirecturl: String?="")

和我的控制器:

public static Result redirect(String redirecturl) { 
   return redirect(redirectURL); 
}

这工作得很好,但是当我传递一个包含分号的网址时,我遇到了问题“;”

如果我去

http:localhost:9000/redirect?redirecturl=http://www.google.com;testaftersemicolon

它将我重定向到google.com,但在我的日志中,redirecturl仅等于分号后停止的“http://www.google.com”。

有办法逃脱吗?或者在游戏中进行自定义路由?

playframework routes playframework-2.0 uri
1个回答
1
投票

您应该能够通过在路径文件中使用自定义正则表达式来转义它。这在the documentation about routing中有描述。基本上类似下面的东西应该工作:

GET     /redirect/$url<.+>            com.test.redirect(url: String?="")
© www.soinside.com 2019 - 2024. All rights reserved.