playframework - Play Framework 是否支持像 rails 这样的嵌套路由?

标签 playframework routes url-routing playframework-2.0

Rails 可以映射在逻辑上属于其他资源的子资源的资源,例如在 URL 中

/magazines/:magazine_id/ads/:id show    display a specific ad belonging to a specific magazine

是否可以在游戏中执行此操作?

最佳答案

Play 不在乎参数是否代表某种关系,这是 Controller 的工作。

当然可以这样做:

GET /some/:parent/:child   controllers.Application.getRelated(parent: Long, child: Long)

在 Controller 中:

public static Result getRelated(Long parent, Long child) {
    return ok(SomeFinder(parent,child));
}

关于playframework - Play Framework 是否支持像 rails 这样的嵌套路由?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11207503/

相关文章:

java - 在 play WS 响应范围中读取变量值

Jquery Mobile getJSON 回调未触发

ruby-on-rails - 在Rails3中覆盖到/(根)的资源路由: not changing the path helper?

Yii框架,如何为后端定义一个url

asp.net-core - ASP 核心中间件中的当前 URL?

java - 在 Play 上使用 Clover 执行代码覆盖!使用 Ant 的框架应用程序

node.js - 在除 server/app.js 之外的路由中使用 socket.io

routes - 如何在 Strope 中路由群聊消息

asp.net-core - 在 ASP.NET Core 3.x MVC 中将 nameof() 与 Url.Action() 和异步方法一起使用

forms - 不支持泛型的嵌套对象 : workarounds