判断一个请求Request是否是ajax请求

public static boolean isAjaxRequest(HttpServletRequest request) {
        String requestedWith = request.getHeader("x-requested-with");
        if (requestedWith != null && requestedWith.equalsIgnoreCase("XMLHttpRequest")) {
            return true;
        } else {
            return false;
        }
    }

 

posted @ 2018-07-04 10:43  小蘇  阅读(5951)  评论(0编辑  收藏  举报