问题
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.
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])
This gives me a not found: Type MyForm-error.
I've tried importing the class:
@import models.form.MyForm
but this doesn't make any difference.
回答1:
You need to fully-qualify MyForm in the first line of your view template when declaring the input parameters:
@(myForm : Form[models.common.MyForm])
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.
来源:https://stackoverflow.com/questions/16402582/models-subpackages-in-play-framework