I'm using Play 2.1 and I'm having some odd problems.
I have a subpackage messages
in the controllers
package with a class i18n.java
.
My routes
file looks like this:
GET \ controllers.messages.i18n.index()
POST \ controllers.messages.i18n.process()
I now have a form with the following action:
@helper.form(action = routes.messages.i18n.process())
but this gives me an error:
value messages is not a member of object controllers.routes
I've used subpackages before in Play 2.0.4 and it worked fine like that, can anyone spot any errors in my configuration?
The routes file doesn't complain that it can't find the controller.
The second parameter, "Blog", is the area name. When matching a URL path like /Manage/Users/AddUser, the "blog_route" route generates the route values { area = Blog, controller = Users, action = AddUser }. The area route value is produced by a default value for area. The route created by MapAreaControllerRoute is equivalent to the following:
Inside the call to UseEndpoints, MapControllerRoute is used to create a single route. The single route is named default route. Most apps with controllers and views use a route template similar to the default route. REST APIs should use attribute routing.
Inside the call to UseEndpoints, MapControllerRoute is used to create a single route. The single route is named default route. Most apps with controllers and views use a route template similar to the default route.
For exemple: /controllers/products.js Starting from my previous article here an exemple of a route and a controller file. As you can see the implementation is very easy and straightforward. Then import all the controller functions. Lastly, use the router object to create a route and controller association.
The route should be controllers.messages.routes.i18n.process()
. You can inspect the target/scala-2.10/src_managed
directory to discover generated files.
And for information, Java coding conventions say that a class must start with an uppercase.
FYI, in 2.2 it's slightly different.
routes.conf looks like:
GET /admin/stuff controllers.admin.StuffController.show()
in code looks like:
controllers.admin.routes.StuffController.show()
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With