Playframework 播放2.2.1 cann';如果父项目具有相同名称的视图,则不调用子播放项目视图

Playframework 播放2.2.1 cann';如果父项目具有相同名称的视图,则不调用子播放项目视图,playframework,playframework-2.2,Playframework,Playframework 2.2,在Play2.2.1中,如果父播放项目具有相同名称的视图(如index.scala.html),我不能调用子播放项目视图 ├── app │   ├── controllers ── Application.scala │   └── views ── index.scala.html ├── conf ── routes ├── others │   └── sub │   ├── app │   │   ├── controllers ── Application.scala

在Play2.2.1中,如果父播放项目具有相同名称的视图(如index.scala.html),我不能调用子播放项目视图

├── app
│   ├── controllers ── Application.scala
│   └── views ── index.scala.html
├── conf ── routes
├── others
│   └── sub
│       ├── app
│       │   ├── controllers ── Application.scala
│       │   └── views
│       │       ├── index.scala.html
│       │       └── subonly.scala.html
│       └── conf ── sub.routes
如何调用子项目index.scala.html

我创建了一个示例项目

条件如下

  • 创建具有相同名称视图的嵌套播放项目,如index.scala.html

    ├── app
    │   ├── controllers ── Application.scala
    │   └── views ── index.scala.html
    ├── conf ── routes
    ├── others
    │   └── sub
    │       ├── app
    │       │   ├── controllers ── Application.scala
    │       │   └── views
    │       │       ├── index.scala.html
    │       │       └── subonly.scala.html
    │       └── conf ── sub.routes
    
  • 将子项目路由添加到父路由中,如
    ->/sub/sub.routes

  • 最后,在父应用程序/视图和子项目应用程序/视图中创建相同名称的视图文件,如index.scala.html

问题 若父项目并没有子项目视图的同名视图,则调用子项目视图

若父项目具有子项目视图的相同名称视图,则在调用子项目视图时,将调用父项目视图

我想称之为同名子项目视图

示例动作 父路由的索引调用父项目index.scala.html

GET     /      controllers.Application.index
->      /sub/  sub.Routes
子项目路由的索引调用subproject index.scala.html(但调用父项目index.scala.html

像这样


从不显示子项目索引查看页面。

我自己解决了这个问题

修复子项目视图目录,如下所示

├── app
├── others
│   └── sub
│       ├── app
│       │   ├── controllers ── Application.scala
│       │   └── views
│       │       └── sub
│       │           ├── index.scala.html
│       │           └── subonly.scala.html
从控制器调用它,就像

def index = Action {
  Ok(views.html.sub.index())
}
它工作正常