ifram预览显示pdf

今天的一个问题是试出来的,有点沾沾自喜
问题描述: 看到某个网站对pdf的预览效果特好,于是自己动手也想实现出来,报了个错 Refused to display … in a frame because it set ‘X-Frame-Options’ to ‘DENY’.
我的项目用到了spring security,版本4.2.5,我先怀疑是security的权限问题,后来发现不是, 然后我在jsp的添加了个meta标签 < meta http-equiv=“X-Frame-Options” content=“sameorigin”> 还是不起作用, 然后看到两个博主的文章受到启发,
https://blog.csdn.net/lizy928/article/details/82535089
https://blog.csdn.net/yangfanj/article/details/80858831
于是我就想能不能再spring security的配置文件了进行配置了,于是就猜是http标签下 然后利用idea的强大的提示功能试出来了

<security:http auto-config="true" use-expressions="true">
        <security:intercept-url pattern="/index.jsp" access="permitAll()"/>
        <security:intercept-url pattern="/item/itemList2" access="hasRole('ROLE_PhoneAdmin')"/>
        <security:intercept-url pattern="/item/itemList3" access="hasAnyAuthority('Authority_Find')"/>
        <security:intercept-url pattern="/jsp/**" access="permitAll()"/>
        <security:intercept-url pattern="/file/**" access="permitAll()"/>
        <security:headers >
            <security:frame-options policy="SAMEORIGIN" />
        </security:headers>

重点是security:headers这个标签

©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页