public class TestServlet extends HttpServlet {
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
String value=request.getHeader("referer");
System.out.println(value);
if(value!=null&&value.startsWith("http://localhost:8080/web04")){
System.out.println("正常访问");
}else{
System.out.println("不可访问");
}
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}