【问题标题】:Escape semicolon route playframework 2.0.2转义分号路由playframework 2.0.2
【发布时间】:2012-08-15 09:55:01
【问题描述】:

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

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”在分号后停止。

有没有办法逃脱它?或者在play里面做一个自定义路由?

【问题讨论】:

    标签: playframework routes playframework-2.0 uri


    【解决方案1】:

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

    GET     /redirect/$url<.+>            com.test.redirect(url: String?="")
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2016-04-15
      • 2011-10-05
      • 2015-08-04
      • 1970-01-01
      • 1970-01-01
      • 2017-12-16
      • 1970-01-01
      • 2012-07-10
      相关资源
      最近更新 更多