2017-10-24 2 views
1

Ich möchte diese iframe in meiner Scala Play-Ansicht anzeigen;Scala Play Framework-URL in Iframe funktioniert nicht

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

Wenn ich diese URL hart Code, funktioniert es. Aber ich möchte, dass es dynamisch ist. Ich habe es versucht;

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

etc ..

Nichts davon funktioniert. In 4 und 5, als ich das Element inspizierte, ist der gesamte src von iframe verschwunden, und ich habe einen iframe mit den Fehlermeldungen Action not found. For request 'GET /%7B%7B%20'http:///hello'%20+%20myclass.section%20+%20'world'%7D%7D' bzw. Action not found. For request 'GET /%7B%7B%20'http://hello'%20+%20myclass.section%20+%20'world'%7D%7D' bekommen. Ich habe Änderungen in application.conf wie play.filters.headers.frameOptions = null vorgenommen. Es benutzt Play 2.4.0.

Wie kann ich das beheben?

Antwort

0

Sie müssen "die Magie‚@‘Zeichen": https://www.playframework.com/documentation/2.6.x/ScalaTemplates

so

<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> 

sein muss oder

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

beide versuchten. Es zeigt 'localahost: 9020/#/group/@ {@ myclass.section}' und im ersten Fall 'localahost: 9020/#/group/@@ myclass.section'. Wenn ich '{{}}' anstelle von '{}' verwende, funktioniert nichts. –