我已将我的项目从 play-slick 0.8 迁移到 play-slick 1.0 ( https://github.com/playframework/play-slick )...这意味着将 play 版本从 2.3 更改为 2.4,将 slick 版本从 2.1 更改为 3.0。
在我的控制器中进行了一些更改后,我的模板中出现了编译错误:
类型不匹配; 找到:play.twirl.api.HtmlFormat.Appendable(扩展为)play.twirl.api.Html 需要:字符串
这是我的模板'createForm.scala.html'。该错误引用了@main 块内的第一行,无论它是什么(在本例中为“添加消防员”)。
@(bomberoForm: Form[Bombero], categorias: Seq[(String, String)])(implicit flash: play.api.mvc.Flash, messages: Messages)
@import helper._
@main {
<h1>Add fireman</h1>
@form(routes.BomberosController.save) {
这是我的'main.html':
@(content: Html)
<!DOCTYPE html>
<html>
<head>
<title>Gestión de turnos</title>
<link rel="stylesheet" type="text/css" media="screen" href="@routes.Assets.at("stylesheets/bootstrap.min.css")">
<link rel="stylesheet" media="screen" href="@routes.Assets.at("stylesheets/main.css")"/>
</head>
<body>
<header class="topbar">
<h1 class="fill">
<a href="@routes.BomberosController.index()">
Gestión de turnos
</a>
</h1>
</header>
<section id="main">
@content
</section>
</body>
</html>
这是我的控制器:
class BomberosController @Inject() (val messagesApi: MessagesApi, bomberos: Bomberos)
extends Controller with I18nSupport {
/**
* This result directly redirect to the bomberos management home.
*/
val Home = Redirect(routes.BomberosController.list(0, 1, ""))
/**
* Describe the bombero form (used in both edit and create screens).
*/
val bomberoForm: Form[Bombero] = Form(
mapping(
"matricula" -> number,
"nombre" -> nonEmptyText,
"apellidos" -> nonEmptyText,
"categoria" -> number,
"fechaDeIngreso" -> jodaLocalDate("dd/MM/yyyy"),
"parque" -> nonEmptyText,
"letra" -> nonEmptyText(1,1)
)((m, n, a, c, f, p, letra) => Bombero(m, n, a, c, f, p, letra.head))
((b: Bombero) => Some(b.matricula, b.nombre, b.apellidos, b.categoria, b.fechaDeIngreso, b.parque, b.letra.toString))
)
def index = Action { Home }
def list(page: Int, orderBy: Int, filter: String) = Action.async { implicit request =>
for {
bomberosList <- bomberos.list(page = page, orderBy = orderBy, filter =("%"+filter+"%"))
} yield
Ok(views.html.bomberos.list(bomberosList, orderBy, filter))
}
def create = Action.async { implicit request =>
for (catOpts <- bomberos.categoriasOptions) yield
Ok(views.html.bomberos.createForm(bomberoForm, catOpts))
}
....
任何想法为什么我会收到此错误?