You are viewing the documentation for the 2.3.x release series. The latest stable release series is 2.5.3.

By default Play binds URLs to controller methods statically, that is, Controller instances are created by the framework and then the appropriate static method is invoked depending on the given URL. In certain situations, however, you may want to manage controller creation and that’s when the new routing syntax comes handy.

Route definitions starting with @ will be managed by play.GlobalSettings#getControllerInstance method, so given the following route definition:

GET     /                  @controllers.Application.index()

Play will invoke play.GlobalSettings#getControllerInstance which in return will provide an instance of controllers.Application (by default this is happening via controllers.Application’s default constructor). Therefore, if you want to manage controller class instantiation either via a dependency injection framework or manually you can do so by overriding getControllerInstance in your application’s Global class.

Here’s an example using Guice:

    import play.GlobalSettings;


    public class Global extends GlobalSettings {

      private static final Injector INJECTOR = createInjector(); 

      public <A> A getControllerInstance(Class<A> controllerClass) throws Exception {
        return INJECTOR.getInstance(controllerClass);

      private static Injector createInjector() {
        return Guice.createInjector();


another example using Spring:

Dokümantasyonun bu çevirisi Play ekibi tarafından yapılmamaktadır. Eğer bir hata bulduysanız, bu sayfanın kaynak kodu burada bulunmaktadır. Dokümantasyon yönergelerini okuduktan sonra lütfen katkı yapmaktan çekinmeyin.