JavaWeb学习记录(二)——防盗链技术

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);
    }

}

上一篇:vSphere存储


下一篇:ios 自定义NSError