-
Notifications
You must be signed in to change notification settings - Fork 141
Spring MVC页面在iframe中显示不出来的解决方法
GeXiangDong edited this page Jan 9, 2019
·
3 revisions
Spring MVC + Spring Security后,页面无法在frame/iframe中显示,chrome 主控台显示:Refused to display 'http://x.x.x.x/xx/' in a frame because it set 'X-Frame-Options' to 'DENY'.
这是因为spring security加了一个header, X-Frame-Options: Deny
可以通过 httpSecurity.headers().frameOptions().disable()
禁止调这个头信息,就可正常在iframe中显示了。
X-Frame-Options 头有三个可选的值:
- DENY
- SAMEORIGIN
- ALLOW-FROM uri
禁止放入ifram可防止被其他网页嵌入,而引发的一些劫持/攻击。