在子文件夹中找不到视图 [英] Can't find view in subfolder

查看:118
本文介绍了在子文件夹中找不到视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚开始使用Play2.0 Framework,我正在尝试在 home / index 模板中使用主模板。我遇到的问题是,当它在Shared文件夹中找不到main时,如果我将它取出并放入Views根目录,那么它可以正常工作。

I just started using the Play2.0 Framework and I'm trying to use the main template in my home/index template. The issue I'm having is it can't find "main" when its in the Shared folder, if I take it out and put it in the Views root then it works fine.

所以我想知道如何从引用 main.scala.html index.scala.html

So I'm wondering how I can reference the main.scala.html from index.scala.html?

我的文件夹结构如下:


  • 查看

    • 主页

      • index.scala.html


      • main.scala.html

      我的代码在 index.scala.html 是:

      @head = {
      
      }
      
      @content = {
          <b>Home Screen</b>!!
      }
      
      ERROR: @main(title = "Home",head, content)
      

      我得到的错误是:

      not found: value main.
      


      推荐答案

      一旦你进入视图的子文件夹就会有这样的感觉伪包称为html。我不完全确定它是如何工作的但是试试这个:

      Once you get into subfolders for views there is this like "pseudo-package" called "html". I'm not entire sure how it works but try this:

      @views.html.Shared.main
      

      这篇关于在子文件夹中找不到视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆