iframe中的Scala Play框架URL无效 [英] Scala Play framework URL in iframe is not working
问题描述
我想在我的scala播放视图中显示此 iframe
;
I want to display this iframe
in my scala play view;
<iframe src="http://localhost:9020/index.html#/group/sectiona/sectionb">Loading...</iframe>
如果我对此网址进行硬编码,则可行。但我希望它是动态的。我试过了;
If I hard code this url, it works. But I want it to be dynamic. I tried;
-
< iframe src =http:// localhost:9020 / index.html#/ group / {{'http:\ // localhost:9020 \ /#\ / group \ /'+ myclass.section +'\ /'+ myclassb.section}} / testtopic> Loading .. 。< / iframe>
-
< iframe src =http:// localhost:9020 / index.html#/ group / {{myclass.section}} / sectionb>正在加载...< / iframe>
-
< iframe class =graphiframesrc ={{'http:\ // hello'+ myclass.section +'world'}}frameborder =0style =overflow:hiddenheight =100%width = 100%>正在加载...< / iframe>
-
< iframe class =graphiframesrc ={ {'http:// hello'+ myclass.section +'world'}}frameborder =0style =overflow:hiddenheight =100%width =100%> Loading ...< ; / iframe>
<iframe src="http://localhost:9020/index.html#/group/{{ 'http:\//localhost:9020\/#\/group\/' + myclass.section + '\/' + myclassb.section }}/testtopic">Loading...</iframe>
<iframe src="http://localhost:9020/index.html#/group/{{myclass.section}}/sectionb">Loading...</iframe>
<iframe class="graphiframe" src="{{ 'http:\//hello' + myclass.section + 'world'}}" frameborder="0" style="overflow:hidden" height="100%" width="100%">Loading...</iframe>
<iframe class="graphiframe" src="{{ 'http://hello' + myclass.section + 'world'}}" frameborder="0" style="overflow:hidden" height="100%" width="100%">Loading...</iframe>
等..
这些都不起作用。在4和5中,当我检查元素时,整个src从iframe消失了,我得到了一个错误消息的iframe 找不到动作。要求'GET /%7B%7B%20'http:///hello'%20+%20myclass.section%20+%20'world'%7D%7D'
和未找到操作。要求'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。
None of this works. in 4 and 5, when I inspected the element, the entire src is gone from iframe, and I got an iframe with error messages Action not found. For request 'GET /%7B%7B%20'http:///hello'%20+%20myclass.section%20+%20'world'%7D%7D'
and Action not found. For request 'GET /%7B%7B%20'http://hello'%20+%20myclass.section%20+%20'world'%7D%7D'
respectively. I have made changes in application.conf like play.filters.headers.frameOptions = null
. It use Play 2.4.0.
我该如何解决这个问题?
How can I fix this?
推荐答案
你需要魔术'@'字符: https:// www。 playframework.com/documentation/2.6.x/ScalaTemplates
You need "the magic ‘@’ character": 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>
这篇关于iframe中的Scala Play框架URL无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!