Good day Everyone,
I am new to Play framework and am trying to get started building an application. Under the app/controllers
folders i have created sub packages so i have something like app/controllers/products/ProductController.class
.
In my routes.conf
file i have added a sample route like this
GET /createproduct controllers.products.ProductController.listAllProducts() POST /createproduct controllers.products.ProductController.createProductDetail()
and i can goto the url http://localhost:9000/createproduct
and see a sample view that i created.
My issue now is that i want to add a form to the view and when i try to use the form helper method to POST data to the POST URL above from my new view like this
@helper.form(action = routes.products.ProductController.createProductDetail()) {
i get the error that
value products is not a member of object controllers.routes
All the samples that i saw online only use the route.Application example which is doesnt fit my issue.
So my question is how do i reverse route to this action or route from a view using the Form helper
The valid syntax is:
[full-package-name].routes.[controller].[method]
So in your case it should be
controllers.products.routes.ProductController.createProductDetail()
controllers.routes
is imported implicity, therefore for using with controllers in default package you can short it to:
routes.Controller.action()
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.