gpt4 book ai didi

scala - 编译错误 : not found: value nonEmptyText in Play framework while using Scala

转载 作者:行者123 更新时间:2023-12-05 01:24:14 24 4
gpt4 key购买 nike

这是我的 Application.Scala

package controllers

import play.api._
import play.api.data.Form
import play.api.mvc._



import _root_.scala.xml.Text


object Application extends Controller {

def index = Action {
Redirect(routes.Application.tasks)
}


def deleteTask(id: Long) = TODO

val taskForm = Form(
"label" -> nonEmptyText
)
def tasks = Action {
Ok(views.html.index(Task.all(), taskForm))
}

def newTask = Action { implicit request =>
taskForm.bindFromRequest.fold(
errors => BadRequest(views.html.index(Task.all(), errors)),
label => {
Task.create(label)
Redirect(routes.Application.tasks)
}
)
}
}

我正在使用 play 2.0 框架。我哪里出错了得到这样的错误?

最佳答案

您可以浏览 Play 2 文档 here .通过查看索引,我发现 nonEmptyText包含在 play.api.data.Forms 中目的。

因此,您需要添加 import play.api.data.Forms._正如已经建议的那样,或者用 Forms.nonEmptyText 替换当前未找到的符号因为它已经导入了。

关于scala - 编译错误 : not found: value nonEmptyText in Play framework while using Scala,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11601455/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com