当前位置:网站首页>点击劫持: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>
以上三种方式都可以,是项目情况而定使用哪种!
边栏推荐
- Scrapy uses xlwt to implement the exporter that exports data in Excel format
- 解决ConfigParser解析中文问题
- 表单校验问题——el-select(初始化页面自动触发校验解决办法)
- What is the lifecycle of automated testing?
- 百度知道爬虫,根据问题id,线索id,评论id获取评论下面的对话
- What pitfalls should be avoided in the job interview for the operation post in 2022?
- window10 phpstudy 安装redis扩展
- Stm32f407 ------- IO pin multiplexing mapping
- What are the virtual machine software? What are their respective roles?
- [C Prime plus chapitre II Questions de programmation après la Classe]
猜你喜欢

【LeetCode】21. Merge two ordered linked lists - go language solution

PHP uses endroid/qrcode QR code to generate, and Gd library generates sharing posters
![[Electronic Experiment 2] simple electronic doorbell](/img/40/227f9ac1f427c1435e0e3aa02640b1.png)
[Electronic Experiment 2] simple electronic doorbell

10、YOLO系列

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

Stm32f407 ------- GPIO input experiment

Notes: three ways to define setters and Getters

11.目标分割

Sword finger offer 12 Path in matrix

Stm32f407 ------ clock system (systeminit clock initialization, systick tick timer)
随机推荐
随笔记:插入排序 --from wcc
Typescript -- Section 3: Interface
Typescript -- Section 1: basic types
TypeScript --第三节:接口
What will be done after digital IC Verification?
Yyds dry goods inventory building knowledge map from scratch with neo4j (I)
Blue Bridge Cup top ten common heaven level skill - breath of water The type of one recursion
Auto encoder
LinkedIn datahub - experience sharing
Baidu knows the crawler, and obtains the dialogue below the comment according to the question Id, clue ID and comment ID
Picture 64base transcoding and decoding
Online yaml to JSON tool
Stm32f407----- capacitive touch button
这玩意叫跳表?
Stm32f407 ------- GPIO input experiment
小白创业做电商,选对商城系统很重要!
MySQL connection query is easy to understand
The secondary market is full of bad news. How should the market go next? One article will show you the general trend
stm32F407-------通用定时器
TypeScript -- 第六节 泛型