在Play框架中建模子包 [英] Models subpackages in Play framework

查看:140
本文介绍了在Play框架中建模子包的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的 models 包中的类列表变得非常大,我想将一些类重构为它们自己的子包。

The list of classes in my models package is getting pretty big and I want to refactor some of the classes into their own subpackage.

例如,所有表格都进入 models.forms ,所有用户都进入 models.users 等等。

For instance, all forms go into models.forms, all users go into models.users, etc.

但是,如果我现在声明一个采用表格的模板:

However if I now declare a template that takes a form:

@(myForm : Form[MyForm])

这给了我未找到:输入MyForm -error。

This gives me a not found: Type MyForm-error.

我尝试导入该类:

@import models.form.MyForm

但这没有任何区别。

推荐答案

你需要完全限定 MyForm

@(myForm : Form[models.common.MyForm])

@确实有点不直观恶魔ort 条目没有任何区别。也许视图模板的编译方式意味着如果自定义类型出现在导入列表之前,则必须完全限定。

It is indeed a bit unintuitive that the @import entry doesn't make any difference. Perhaps the way in which view templates are compiled means that custom types have to be fully qualified if they occur before the list of imports.

这篇关于在Play框架中建模子包的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆