简体   繁体   中英

How to use `controllers.Default.redirect` in Play 2.4 and `InjectedRoutesGenerator`

If I try to use controllers.Default.redirect(to = "/foo/bar") in my routes file with routesGenerator := InjectedRoutesGenerator enabled in my build.sbt file, I get the compilation error

type Default is not a member of package controllers

With this new injected routes feature in Play 2.4 is there still a way to use handlers defined in static objects?

No there's not. Default should be made a class so it can be used from an injected router, with a companion object that extends it so it can still be used from the static router. Please raise an issue in the Play issue tracker, or better, submit a pull request to fix this.

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM