iframe中的Scala Play框架URL无效 [英] Scala Play framework URL in iframe is not working

查看:228
本文介绍了iframe中的Scala Play框架URL无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的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;


  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>正在加载...< / iframe>

  3. < iframe class =graphiframesrc ={{'http:\ // hello'+ myclass.section +'world'}}frameborder =0style =overflow:hiddenheight =100%width = 100%>正在加载...< / iframe>

  4. < iframe class =graphiframesrc ={ {'http:// hello'+ myclass.section +'world'}}frameborder =0style =overflow:hiddenheight =100%width =100%> Loading ...< ; / iframe>

  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>

等..

这些都不起作用。在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屋!

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