1
嘗試使用簡單控制器播放框架2.5時遇到的錯誤消息令人困惑。下面是我在做什麼:上面寫着使用簡單控制器播放框架2.5錯誤
object UserController extends Controller {
def login = Action.async(BodyParsers.parse.json) { request =>
val body = request.body.validate[UserLogin]
// call the userService and validate the credentials
body.fold(
errors => {
BadRequest(Json.obj("status" -> "error", "message" -> JsError.toFlatJson(errors)))
}, // error here
message => {
Ok("")
} // error here
)
}
}
我收到錯誤消息:
"Expression of type Result does not conform to expected type _X"
我想你可以刪除「異步」呼叫或在「Future.successful」包裹TWE響應 – rethab