我一直在使用 Scala 的 Play 框架,但遇到了一些麻烦。
我正在尝试从 Controller 方法调用另一个 Controller 方法。首先,我尝试使用 WSRequest/Response 来调用其他 Controller 方法的路由,但是 WSResponse 不包含任何内容!没有 Cookie 或 header 即使 Controller 的方法会返回 WithCookies 重定向。
另外,我不确定如何直接调用 Controller 方法,因为它返回 EssentialAction,但第一个方法使用需要 Future[Result] 的隐式请求 ActionAsync 方法。我将如何使用 EssentiaLAction 创造 future [结果]!!?
关于如何解决我的问题有什么想法吗?谢谢!
最佳答案
def a(s: String): Action[AnyContent] = Action.async {
Future(Ok(s))
}
def b: Action[AnyContent] = Action.async {request =>
a("from b")(request)
}
关于java - Play Scala 从另一个方法调用 Controller 方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37284191/