Nna*_*noh 0 java playframework-2.3
今天是个好日子,
我是Play框架的新手,我正在尝试开始构建应用程序.在app/controllers我创建子包的文件夹下,所以我有类似的东西app/controllers/products/ProductController.class.
在我的routes.conf文件中,我添加了这样的示例路线
GET /createproduct controllers.products.ProductController.listAllProducts()
POST /createproduct controllers.products.ProductController.createProductDetail()
我可以转到网址http://localhost:9000/createproduct并查看我创建的示例视图.
我现在的问题是我想在视图中添加一个表单,当我尝试使用表单助手方法从我的新视图中将数据POST到上面的POST URL时
@helper.form(action = routes.products.ProductController.createProductDetail()) {
我得到了错误
value products is not a member of object controllers.routes
我在网上看到的所有样本只使用route.Application示例,这不适合我的问题.
所以我的问题是我如何使用Form帮助器从一个视图反向路由到此操作或路由
有效的语法是:
[full-package-name].routes.[controller].[method]
Run Code Online (Sandbox Code Playgroud)
所以在你的情况下它应该是
controllers.products.routes.ProductController.createProductDetail()
Run Code Online (Sandbox Code Playgroud)
controllers.routes 是导入的隐含,因此对于在默认包中使用控制器,您可以将其缩短为:
routes.Controller.action()
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
751 次 |
| 最近记录: |