使用 X-Frame-Options 防止被iframe 造成跨域iframe 提交挂掉

 Refused to display 'http://www.***.com/login/doLogin.html' in a frame because it set 'X-Frame-Options' to 'SAMEORIGIN'. 

我们需要在web.xml中添加

X-Frame-Options 有三个值:

1、X-Frame-Options:DENY  

  表示该页面不允许在 frame 中展示,即便是在相同域名的页面中嵌套也不允许。

2、X-Frame-Options:SAMEORIGIN

表示该页面可以在相同域名页面的 frame 中展示。

3:X-Frame-Options:ALLOW-FROM uri

表示该页面可以在指定来源的 frame 中展示。


<filter>
<filter-name>httpHeaderSecurity</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
<init-param>
<param-name>antiClickJackingEnabled</param-name>
<param-value>true</param-value>
</init-param>
<init-param>
<param-name>antiClickJackingOption</param-name>
<param-value>SAMEORIGIN</param-value>
</init-param>
<async-supported>true</async-supported>
</filter>
<filter-mapping>
<filter-name>httpHeaderSecurity</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

修改对应的antiClickJackingOption即可

X-Frame-Options防止网页放在iframe中

二、对应的IIS

配置 IIS 发送 X-Frame-Options 响应头,添加下面的配置到 Web.config 文件中:

 

X-Frame-Options防止网页放在iframe中

 

详细参考:https://www.jb51.net/article/109436.htm

 

相关文章:

  • 2022-12-23
  • 2021-07-05
  • 2021-07-17
  • 2021-10-10
  • 2022-12-23
  • 2022-01-22
  • 2022-12-23
猜你喜欢
  • 2021-12-03
  • 2022-03-02
  • 2021-10-28
  • 2021-11-18
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案