更新时间:2023-09-23 23:00:04
根据 文档:
Play 支持生成两种路由,一种是依赖注入路由器,另一个是静态路由器.默认是静态路由器,但如果您使用播放种子激活器模板,您的项目将包括以下内容build.sbt
中的配置告诉它使用注入的路由器:
Play supports generating two types of routers, one is a dependency injected router, the other is a static router. The default is the static router, but if you created a new Play application using the Play seed Activator templates, your project will include the following configuration in
build.sbt
telling it to use the injected router:
routesGenerator := InjectedRoutesGenerator
Play 文档中的代码示例假定您正在使用注入的路由生成器.如果你不使用这个,你可以简单地调整静态路由生成器的代码示例,或者通过在路由的控制器调用部分加上前缀一个 @
符号,或者通过将每个控制器声明为一个 object
而不是 class
.
The code samples in Play’s documentation assumes that you are using
the injected routes generator. If you are not using this, you can
trivially adapt the code samples for the static routes generator,
either by prefixing the controller invocation part of the route with
an @
symbol, or by declaring each of your controllers as an object
rather than a class
.
Java 中的等效项是静态与非静态.
The equivalent in Java would be static vs non-static.