我在Scala中有这个控制器:
def commonRedirect(anId: Long) = {
implicit val aRule = CommonClient.getTheRule(anId)
aRule match {
case false ? Redirect("/general-rule/" + anId)
case true ? Redirect("/custom-rule/" + anId)
}
Run Code Online (Sandbox Code Playgroud)
}
但是,这导致错误:"无法使用返回play.api.mvc.Result作为请求处理程序的方法".
如果我应用动作生成器,它可以工作,但这不是我想要的方式.
有什么想法解决这个问题?
谢谢.
我使用 Apache Cordova 实现了一个应用程序,并使用了 $cordovaCamera 插件。当 $cordovaCamera 的源类型是 Camera.PictureSourceType.PHOTOLARY 时,输出类似于
“内容://com.android.providers.media.documents/document/image”
并且,当我使用 Camera.PictureSourceType.CAMERA 时,我得到
“file:///storage/emulated/0/Android/data/com.ionic.viewapp/cache/image.jpg”。
在我的情况下,格式“file://..”更有用。
是否可以从内容 URI 中获取文件 URI?
我找到了这个问题的很多答案,但所有解决方案都是针对 JAVA,而不是针对 Javascript。
我找到了以下代码,我不确定它是如何工作的.这是Play框架的Scala代码.
## route file ##
GET /:object @controllers.ResultsController.resultController(object)
Run Code Online (Sandbox Code Playgroud)
## ResultsController file ##
def resultController(object: SomeObject) = {
getResult(object)
}
def private getResult(object: SomeObject): Result = {
lazy val result = computeResult(object) match {
case Some(response) => JsonOk(response)
case None => JsonInternalError(...)
}
result
}
Run Code Online (Sandbox Code Playgroud)
我不确定什么时候result被评估.我的意思是,返回是必须在使用时评估的东西,还是在返回时解决的?
懒惰的特征离开了函数的上下文?
在这种情况下,从不使用该值,仅作为GET请求的结果返回.
非常感谢!!!