当前位置:网站首页>点击劫持:X-Frame-Options未配置
点击劫持:X-Frame-Options未配置
2022-06-28 23:57:00 【hay_lee】
X-Frame-Options未配置
可以配置的参数有三个:
1.DENY:浏览器拒绝当前页面加载任何Frame页面。
2.SAMEORIGIN:页面只能加载入同源域名下的页面。
3.ALLOW-FROM uri:只能被嵌入到指定域名的框架中。
一般选第二个参数就可以了。
方式一:每个页面添加设置:
<% response.addHeader("x-frame-options","SAMEORIGIN");%>
方式二:项目代码中加过滤器设置:
public class FrameFilter implements Filter {
public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
HttpServletRequest request = (HttpServletRequest) req;
HttpServletResponse response = (HttpServletResponse) res;
//设置x-frame-options
response.setHeader("x-frame-options", "SAMEORIGIN");
chain.doFilter(request, response);
}
public void init(FilterConfig config) throws ServletException {
}
public void destroy() {
}
}
然后web.xml中配置此过滤器,不再赘述。
方式三:tomcat中设置(如果使用的服务器是tomcat,可以在tomcat中设置,tomcat下所有应用都会生效)
tomcat目录/conf/web.xml中的找httpHeaderSecurity配置,将其前面的注释去掉即可。
<filter-mapping>
<filter-name>httpHeaderSecurity</filter-name>
<url-pattern>/*</url-pattern>
<dispatcher>REQUEST</dispatcher>
</filter-mapping>
<filter>
<filter-name>httpHeaderSecurity</filter-name>
<filter-class>org.apache.catalina.filters.HttpHeaderSecurityFilter</filter-class>
<async-supported>true</async-supported>
// 添加以下代码start
<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> //添加end
</filter>
以上三种方式都可以,是项目情况而定使用哪种!
边栏推荐
- 10、YOLO系列
- ERROR 1067 (42000): Invalid default value for ‘end_ time‘ Mysql
- 【C Primer Plus第二章课后编程题】
- MapReduce案例
- fio的IO重放功能
- stm32F407-------外部中断
- Xiaobai's e-commerce business is very important to choose the right mall system!
- Phoenix installation tutorial
- Have you ever met a fake interview in a job interview? How to avoid?
- Stm32f407 ------ serial (serial port) communication
猜你喜欢

Blue Bridge Cup top ten common heaven level skill - breath of water The type of one recursion

Give you a project, how will you carry out performance testing (I)

ctfshow XSS
![[software analysis] iterative explanation of software analysis, design and modeling](/img/37/1163fec464aed365d1ea04e63a0c90.png)
[software analysis] iterative explanation of software analysis, design and modeling

MapReduce case
![[machine learning] numerical analysis 02 -- finding roots of arbitrary equations](/img/fd/ec82a50017e692ac90f6e8739b28d3.jpg)
[machine learning] numerical analysis 02 -- finding roots of arbitrary equations

ERROR 1067 (42000): Invalid default value for ‘end_ time‘ Mysql

Behaviortree in ros2

随笔记:定义setter和getter的三种方式

stm32F407-------串行(串口)通信
随机推荐
stm32F407-------跑马灯、蜂鸣器
PHP利用CURL实现登录网站后下载Excel文件
fio的IO重放功能
With notes: insert sort --from WCC
Typescript -- Section 6 generic
Is it reliable and safe to avoid five in case of stock trading account opening
Huawei's level 22 experts have worked hard for ten years to complete the advanced practical document of cloud native service grid. 6
Stm32f407 ------- GPIO input experiment
表单校验问题——el-select(初始化页面自动触发校验解决办法)
stm32F407-------外部中断
Blue Bridge Cup top ten common heaven level skill - breath of water The type of one recursion
Reading notes of English grammar new thinking Basic Edition 2 (I)
PHP uses endroid/qrcode QR code to generate, and Gd library generates sharing posters
stm32F407-------LCD
Sword finger offer 12 Path in matrix
Stm32f407 ------- IO pin multiplexing mapping
Machine learning 6-decision tree
Solve the problem of Chinese parsing by configparser
[buuctf.reverse] 131-135
MySQL connection query is easy to understand