我已經定義像這樣的路線:不能通過參數扭轉路由器在playframework
GET /login controllers.Login.showForm(continue: Option[String] = None)
Login.showForm這是:
def showForm(continue: Option[String] = None) = Action { implicit request =>
val nextPage = continue match {
case None => routes.CtrlIndex.index().absoluteURL().toString()
case Some(page) => page
}
Ok(views.html.login(nextPage))
}
現在,使用動作組合物I製成的認證在用戶未通過身份驗證時執行此操作的操作:
val continue =
if (request.method == "GET") request.uri
else routes.CtrlIndex.index().absoluteURL().toString() // This is not code duplication for reasons that are out of the scope of this question.
Redirect(routes.Login.showForm(Some(continue)))
這不能與我一起編譯ssage:
too many arguments for method showForm:()play.api.mvc.Call
[error] Redirect(routes.Login.showForm(Some(continue)))
改變路線定義使得它的工作:
GET /login controllers.Login.showForm(continue: Option[String])
但是當我使用JavaScript反向路由器,它產生在生成的JavaScript以下錯誤:
SyntaxError: missing formal parameter
function(continue) {
---------^
我已經嘗試了函數簽名定義的所有組合,但是當JavaScript工作時,其他工作站停止工作或以其他方式工作。我如何使用
- 可選參數上/登錄
- 使用反向JavaScript的路由器
- 重定向到與「繼續」參數/登錄
- 我也想改變
request.uri
的東西,返回絕對路徑。
在此先感謝
PS。如果你看到西班牙文的東西,請告訴我,我會解決它,代碼最初是用西班牙文;即使閱讀之後,我可能錯過了一些東西。
哦,男人,我覺得自己像一個白癡。在光明的一面,我想這不會再咬我一口。謝謝! – Roger 2014-09-14 17:20:43