问题 播放2:模板中的“对表单的引用是模糊的”错误消息


我试图按照书中的代码示例构建一个play2应用程序: 我在创建具有以下定义的表单模板时遇到了绊脚石:     @(productForm:Form [Product])

@main("Product Form") {
<h1>Product Form</h1>
@helper.form(action = routes.Products.save()) {
    <fieldset>
    <legend> Product (@productForm("name").valueOr("new"))</legend>
    @helper.inputText(productForm("wan"), '_label -> "EAN")
    @helper.inputText(productForm("name"), 'label -> "Name")
    @helper.textarea(productForm("description"), '_label -> "Description")
    </fieldset>
    <input type"submit" class="btn btn-primary" value="Save">
    <a a class=btn" href="@routes.Products.list()"> Cancel </a>
    }
 }

我得到以下eclipse(我安装了scala ide插件)

Multiple annotations found at this line:
    - reference to Form is ambiguous; it is imported twice in the same scope by import play.data._ and 
 import play.api.data._

我应该忽略这条消息吗? play compile 运行正常,但我没有从表单中获得任何输出。


2371
2018-01-14 17:43


起源

您使用的是什么版本的Play?消息来自哪条线? - 2manyprojects
我用play 2.2.1。在进行了一些深度错误搜索后,表单现在可以正常工作,但错误消息仍在继续。所以我猜代码是对的但是Eclipse错了! - Manu


答案:


要纠正我必须插入的日食错误

 @(productForm: play.data.Form[Product])

代替:

 @(productForm: Form[Product])

9
2018-01-16 18:13



谢谢,这对我有用。 - Philihp Busby
但是在编写游戏时,这不是问题。为什么代码要更加冗长以满足eclipse? - Oliver Shaw