我找到了解决方案。X-frame-
Options响应标头需要通过Tomcat服务器上的web.xml添加。我的web.xml中缺少过滤器映射,因此没有添加标头。对于其他可能会遇到此问题的人,我在这里发布来自web.xml的代码行:
<filter> <filter-name>httpHeaderSecurity</filter-name> <filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class> <async-supported>true</async-supported> <init-param> <param-name>antiClickJackingEnabled</param-name> <param-value>true</param-value> </init-param> <init-param> <param-name>antiClickJackingOption</param-name> <param-value>DENY</param-value> </init-param> </filter> <filter-mapping> <filter-name>httpHeaderSecurity</filter-name> <url-pattern>/*</url-pattern></filter-mapping> <welcome-file-list> <welcome-file>index.html</welcome-file> </welcome-file-list>
这样,将添加以下标头:•X-frame-Options•X-Content-Type-Options•X-XSS-Protection
如果不为每个标头指定值,则将设置每个标头的默认值。您可以在Tomcat服务器文档中找到默认值。



