/**
* 使用Refresh请求头,来防盗链
*/
String refer=request.getHeader("Referer");
System.out.println("请求头:"+refer);
/**
* 如果为空或者不包含local host定向到百度否者输出hello
*/
if (refer==null||!refer.contains("localhost")) {
response.sendRedirect("http://www.baidu.com");
}
else {
System.out.println("hello!");
}
使用referer请求头完成防盗链
最新推荐文章于 2025-09-22 16:09:18 发布
本文介绍了一种通过检查HTTP请求头中的Referer字段来实现防盗链的方法。如果Referer为空或不包含'localhost',则将请求重定向到百度;否则,输出'hello!'。这是一种简单有效的防盗链策略。
8116

被折叠的 条评论
为什么被折叠?



