Playframework 如何在playframwork模板中访问枚举

Playframework 如何在playframwork模板中访问枚举,playframework,playframework-2.4,Playframework,Playframework 2.4,我有一个带有枚举字段的模型类 @Entity public class Product implements Serializable{ @Id @GeneratedValue public long id; @Enumerated(EnumType.STRING) public ProductType type; } 我正在将它从一个动作推到模板 public Result index() { List<Product>

我有一个带有枚举字段的模型类

@Entity
public class Product implements Serializable{

    @Id
    @GeneratedValue
    public long id;

    @Enumerated(EnumType.STRING)
    public ProductType type;
}
我正在将它从一个动作推到模板

public Result index() {
        List<Product> products = getProducts();
        return ok(index.render(products));
    }
公共结果索引(){
List products=getProducts();
返回ok(索引渲染(产品));
}
现在我无法访问模板中产品的枚举字段。我试过这种方法,但没有成功

@for(product <- products){
                    <h1>@product.type</h1>
}

@for(product问题在于
type
在Scala中是一个保留字(比如Java中的
public
class
)。您可以使用反勾号将其转义:

@for(product <- products){
    <h1>@product.`type`</h1>
}
(产品)的
@