Eclipse 玩框架编译错误-未找到:值id

Eclipse 玩框架编译错误-未找到:值id,eclipse,scala,playframework,playframework-2.0,Eclipse,Scala,Playframework,Playframework 2.0,我正在使用URI路由!这是第一次。这就是我所拥有的: EclipseIDE,更新良好的IMHO 错误: Compilation error - not found: value id In C:\play\play-2.2.1\samples\java\forms\app\views\contact\form.scala.html at line 7. @import helper.twitterBootstrap._ @title = { Add a new contact <

我正在使用URI路由!这是第一次。这就是我所拥有的:

  • EclipseIDE,更新良好的IMHO

  • 错误:

    Compilation error - not found: value id
    In C:\play\play-2.2.1\samples\java\forms\app\views\contact\form.scala.html at line 7.
    
    
    @import helper.twitterBootstrap._
    
    @title = {
      Add a new contact <small><a href="@routes.Contacts.edit(id: Long)">Or edit an existing contact</a></small> 
    }
    
    @phoneField(field: Field, className: String = "phone") = {
      @input(field, '_label -> "Phone numbers", '_class -> className) { (id, name, value, _) =>
      ...
    
  • 控制器:

    public static Result edit(Long id) {
        Contact existingContact = Contact.find.byId(3L);
        return ok(form.render(contactForm.fill(existingContact)));
    }
    

好了,就这样!我还能查什么?谢谢大家!

当您参考
routes.Contacts.edit
route时,您需要传递一个id。现在,您似乎只是复制了参数声明(例如
id:Long
),而没有选择一个有意义的id来传递

声明
title
块以接受
id
作为参数,例如:

@title(id: Long) = {
  Add a new contact <small><a href="@routes.Contacts.edit(id)">Or edit an existing contact</a></small> 
}
@title(id: Long) = {
  Add a new contact <small><a href="@routes.Contacts.edit(id)">Or edit an existing contact</a></small> 
}
@title(someId)