【发布时间】:2013-04-17 00:50:27
【问题描述】:
我是 Java 新手,我正在为一个项目使用 play framework 2.0,并且想知道如何使用反向路由功能。我们有以下内容:
在路由文件中
GET / controllers.Application.index()
GET /myapp/storage controllers.myapp.AnotherController.index()
所以要使用反向路由:
controllers.routes.ref.Application.index()
但是AnotherController 呢?
如果我在测试中使用controllers.routes.ref.AnotherController.index(),播放框架会抛出错误“找不到符号”。
谢谢。
【问题讨论】:
-
为什么不把您的 AnotherController.java 也放在 app.controllers 包中?
-
我希望将控制器分组到单独的包中。当使用定义的路由“GET /test controllers.myapp.AnotherController.index()”发出 GET 请求时,播放框架解决了它没有问题。所以我希望反向路由也适用于这种设置。
-
你试过
ontrollers.routes.ref.myapp.AnotherController.index()吗? -
是的,我尝试了 controllers.routes.ref.myapp.AnotherController.index() 并报告找不到符号 myapp。 avik 建议的效果非常好...... controllers.myapp.routes.AnotherController.index.