【问题标题】:Allow loading of my own website into iframe允许将我自己的网站加载到 iframe
【发布时间】:2014-03-19 20:47:50
【问题描述】:

有任何方法可以禁用此安全验证:

Load denied by X-Frame-Options: http://localhost:8080/mywebsite/page/1 does not permit framing.

发生这种情况是因为我正在尝试将自己的 url 添加到我的应用程序的 iframe 中。

我尝试在上面的 url 中响应的页面中做这样的事情:

<% response.addHeader("X-Frame-Options", "ALLOW-FROM: localhost"); %>
<% response.addHeader("X-Frame-Options", "ALLOW"); %>
<% response.addHeader("X-Frame-Options", "SAME-ORIGIN"); %>

它们都不起作用!

【问题讨论】:

  • 不,两者都在同一台服务器上运行@RobSedgwick

标签: java javascript jsp firefox iframe


【解决方案1】:

以下代码解决了我的问题:

@RequestMapping(value="/page/{id}", method=RequestMethod.GET)
public @ResponseBody ModelAndView load(@PathVariable String id, HttpServletResponse response) {
response.setHeader("X-FRAME-OPTIONS", "SAMEORIGIN");

Map<String,Object> parameters = new HashMap<String,Object>();
...
return new ModelAndView("page", parameters);

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-08
    • 2011-08-25
    • 1970-01-01
    • 2022-11-04
    • 1970-01-01
    相关资源
    最近更新 更多