当前位置:网站首页>通过Referer请求头实现防盗链
通过Referer请求头实现防盗链
2022-07-25 11:21:00 【JackLi0812】
通过Referer请求头实现防盗链
<a href="${pageContext.request.contextPath }/NewsServlet">重磅新闻</a>public class NewsServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
response.getWriter().write("本大侠吃包子....");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}
public class NewsServlet extends HttpServlet {
private static final long serialVersionUID = 1L;
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
response.setContentType("text/html;charset=utf-8");
String referer = request.getHeader("Referer");
if(referer == null || "".equals(referer) || !referer.contains("localhost/")) {
response.sendRedirect(request.getContextPath() + "/index.jsp");
return;
}
response.getWriter().write("本大侠吃包子....");
}
protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
doGet(request, response);
}
}

边栏推荐
- 硬件连接服务器 tcp通讯协议 gateway
- R语言可视化散点图、使用ggrepel包的geom_text_repel函数避免数据点之间的标签互相重叠(设置min.segment.length参数为Inf不添加标签线段)
- Median (二分答案 + 二分查找)
- 创新突破!亚信科技助力中国移动某省完成核心账务数据库自主可控改造
- [cloud co creation] what is the role of AI in mathematics? What will be the disruptive impact on the mathematical world in the future?
- winddows 计划任务执行bat 执行PHP文件 失败的解决办法
- brpc源码解析(一)—— rpc服务添加以及服务器启动主要过程
- Week303 of leetcode (20220724)
- PL/SQL入门,非常详细的笔记
- 奉劝那些刚参加工作的学弟学妹们:要想进大厂,这些并发编程知识是你必须要掌握的!完整学习路线!!(建议收藏)
猜你喜欢
![[comparative learning] understanding the behavior of contractual loss (CVPR '21)](/img/96/9b58936365af0ca61aa7a8e97089fe.png)
[comparative learning] understanding the behavior of contractual loss (CVPR '21)

从云原生到智能化,深度解读行业首个「视频直播技术最佳实践图谱」

【GCN-RS】Learning Explicit User Interest Boundary for Recommendation (WWW‘22)

Power BI----这几个技能让报表更具“逼格“
![There is no sound output problem in the headphone jack on the front panel of MSI motherboard [solved]](/img/e8/d663d0a3c26fce8940f91c6db4afdb.png)
There is no sound output problem in the headphone jack on the front panel of MSI motherboard [solved]

剑指 Offer 22. 链表中倒数第k个节点

JS operator

brpc源码解析(七)—— worker基于ParkingLot的bthread调度

Sword finger offer 22. the penultimate node in the linked list

那些离开网易的年轻人
随机推荐
Start with the development of wechat official account
Learning to pre train graph neural networks
dirReader.readEntries 兼容性问题 。异常错误DOMException
Transformer variants (spark transformer, longformer, switch transformer)
Objects in JS
【高并发】SimpleDateFormat类到底为啥不是线程安全的?(附六种解决方案,建议收藏)
小程序image 无法显示base64 图片 解决办法 有效
Risks in software testing phase
PHP curl post x-www-form-urlencoded
PL/SQL入门,非常详细的笔记
[cloud co creation] what is the role of AI in mathematics? What will be the disruptive impact on the mathematical world in the future?
【AI4Code】《CoSQA: 20,000+ Web Queries for Code Search and Question Answering》 ACL 2021
brpc源码解析(八)—— 基础类EventDispatcher详解
PHP curl post length required error setting header header
brpc源码解析(二)—— brpc收到请求的处理过程
剑指 Offer 22. 链表中倒数第k个节点
已解决 Files‘ name is invalid or does not exist (1205)
[high concurrency] Why is the simpledateformat class thread safe? (six solutions are attached, which are recommended for collection)
winddows 计划任务执行bat 执行PHP文件 失败的解决办法
【GCN-RS】Towards Representation Alignment and Uniformity in Collaborative Filtering (KDD‘22)