黑马程序员技术交流社区
标题:
在做防盗链的时候弹404,纠结死了
[打印本页]
作者:
hhmm665544
时间:
2014-4-20 22:49
标题:
在做防盗链的时候弹404,纠结死了
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String referer = request.getHeader("referer");
if(referer==null || !referer.startsWith("http://localhost")){
response.sendRedirect("/day6/index.jsp");
return;
}
response.setCharacterEncoding("UTF-8");
response.setContentType("text/html;charset=UTF-8");
String data = "采访凤姐日记";
response.getWriter().write(data);
}
复制代码
<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>My JSP 'index.jsp' starting page</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<a href="/day6/servlet/ResponseDemo3">查看图书</a></br>
<a href="/day6/servlet/ResquestDemo4">看凤姐</a></br>
<a href="/day6/servlet/RequestDemo1">查看URL</a>
</body>
</html>
复制代码
第一次输入的时候会跳转到主页去,从主页点了就出现404了
欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/)
黑马程序员IT技术论坛 X3.2