我有一个模块,它有一个控制器和几个模板。现在,我想引用位于父模块中的控制器。我想这样的:如何在Play中使用父模块中定义的路由?
case Some(user) => Redirect(routes.Application.index)
不幸的是,我收到以下错误:
[error] case Some(user) => Redirect(routes.Application.index)
[error] ^
我试了也是这样的:
case Some(user) => Redirect(controllers.Application.index)
但我得到的仍是同样的错误。当我试图引用作为模块一部分的控制器时,也会发生此错误。
我试过像这样:controllers.module.Controller.action
。
另外,在模块中引用视图时,我也遇到了同样的问题,这些模块实际上位于父视图中。
例如,我要引用的模板main
模块中:
@views.html.main
它抛出一个错误。
非常感谢您的帮助!你能告诉我如何在我的控制器和模板中引用路线吗? –
我使用Java,并且我在子项目中的代码看起来像是'controllers.routes.Assets.versioned(new controllers.Assets.Asset(url))。toString()',其中'url'只是一个字符串。我想,你需要调用'Redirect(controllers.routes.Application.index)'。 –
完美的作品!非常感谢。 –