Routes and subpackages in controllers

前端 未结 3 689
滥情空心
滥情空心 2021-02-19 09:06

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

相关标签:
3条回答
  • 2021-02-19 09:08

    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()
    
    0 讨论(0)
  • 2021-02-19 09:10

    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.

    0 讨论(0)
  • 2021-02-19 09:12

    For Play 2.4.6 Java users:

    Let's say your controller (Application) and action (logout) is com.stackoverflow.play.Application.logout().

    To use it in your template (*.scala.html), you do @com.stackoverflow.play.routes.Application.logout (e.g., <a href="@com.stackoverflow.play.routes.Application.logout()">, <form action="@com.stackoverflow.play.routes.Application.logout()" method="post">).

    Read the bottom part of this link: https://playframework.com/documentation/2.4.x/JavaRouting

    0 讨论(0)
提交回复
热议问题