【问题标题】:Scala Play framework URL in iframe is not workingiframe 中的 Scala Play 框架 URL 不起作用
【发布时间】:2018-04-05 19:06:19
【问题描述】:

我想在我的 scala 播放视图中显示这个 iframe

<iframe src="http://localhost:9020/index.html#/group/sectiona/sectionb">Loading...</iframe>

如果我对这个网址进行硬编码,它就可以工作。但我希望它是动态的。我试过了;

  1. &lt;iframe src="http://localhost:9020/index.html#/group/{{ 'http:\//localhost:9020\/#\/group\/' + myclass.section + '\/' + myclassb.section }}/testtopic"&gt;Loading...&lt;/iframe&gt;
  2. &lt;iframe src="http://localhost:9020/index.html#/group/{{myclass.section}}/sectionb"&gt;Loading...&lt;/iframe&gt;
  3. &lt;iframe class="graphiframe" src="{{ 'http:\//hello' + myclass.section + 'world'}}" frameborder="0" style="overflow:hidden" height="100%" width="100%"&gt;Loading...&lt;/iframe&gt;
  4. &lt;iframe class="graphiframe" src="{{ 'http://hello' + myclass.section + 'world'}}" frameborder="0" style="overflow:hidden" height="100%" width="100%"&gt;Loading...&lt;/iframe&gt;

等等。

这些都不起作用。在 4 和 5 中,当我检查元素时,整个 src 都从 iframe 中消失了,我得到了一个 iframe,分别带有错误消息 Action not found. For request 'GET /%7B%7B%20'http:///hello'%20+%20myclass.section%20+%20'world'%7D%7D'Action not found. For request 'GET /%7B%7B%20'http://hello'%20+%20myclass.section%20+%20'world'%7D%7D'。我在 application.conf 中进行了更改,例如 play.filters.headers.frameOptions = null。它使用 Play 2.4.0。

我该如何解决这个问题?

【问题讨论】:

    标签: java scala iframe playframework playframework-2.0


    【解决方案1】:

    你需要“神奇的‘@’字符”:https://www.playframework.com/documentation/2.6.x/ScalaTemplates

    所以

    <iframe src="http://localhost:9020/index.html#/group/{{myclass.section}}/sectionb">Loading...</iframe>
    

    必须是

    <iframe src="http://localhost:9020/index.html#/group/@myclass.section/sectionb">Loading...</iframe>
    

    <iframe src="http://localhost:9020/index.html#/group/@{myclass.section}/sectionb">Loading...</iframe>
    

    【讨论】:

    • 都试过了。它显示localahost:9020/#/group/@{@myclass.section},在第一种情况下显示localahost:9020/#/group/@@myclass.section。如果我使用{{ }} 而不是{ },则没有任何效果。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-05-27
    • 2015-01-20
    相关资源
    最近更新 更多