当前位置: 代码迷 >> 综合 >> Refused to display ‘https://localhost:8080/msc/ordertype’ in a frame because it set ‘X-Frame-Options
  详细解决方案

Refused to display ‘https://localhost:8080/msc/ordertype’ in a frame because it set ‘X-Frame-Options

热度:22   发布时间:2024-01-04 01:16:35.0

原因:
Spring-Security 默认是设置了这个 “X-Frame-Options” 属性为DENY

解决:

一:使用xml

<http auto-config="true" use-expressions="true"><headers><frame-options policy="SAMEORIGIN"></frame-options></headers></http>

二:利用java代码

老版本

http.headers().addHeaderWriter(new XFrameOptionsHeaderWriter(XFrameOptionsHeaderWriter.XFrameOptionsMode.SAMEORIGIN))

版本Spring Security 4.0.2

http.headers().frameOptions().sameOrigin();

 

  相关解决方案