在超类中,我定义了一个函数:
def render(model: JsonModel) {
if (!model.isOk()) {
BadRequest(model.toJsonString()).withHeaders("Content-Type" -> "application/json; charset=utf-8")
} else {
Ok(model.toJsonString()).withHeaders("Content-Type" -> "application/json; charset=utf-8")
}
}
我想在我的子类中调用这个函数:
def test(model: JsonModel) = Action { implicit request =>
render(model)
}
这不起作用并抱怨 - 类型不匹配;找到:需要单位
如果我摆脱隐含的请求
def test(model: JsonModel) = Action {
render(model)
}
它似乎有效,但我有时需要访问请求