package com.neusoft.knowledge.common.utils;

import javax.servlet.http.HttpServletRequest;

/**
 * @Title:WebServiceUtils.
 * @Content:com.neusoft.knowledge.common.utils.WebServiceUtils
 * @Description:ajax请求工具类
 * @Author:Marklin
 * @DateTime:2017-10-09 22:20
 * @Version:1.0version
 */
public class WebServiceUtils {
    /**
     * 判断请求是否是ajax请求
     *
     * @param request
     * @return
     */
    public static boolean isAjaxRequest(HttpServletRequest request) {
        if (request.getHeader("accept").indexOf("application/json") > -1
                || (request.getHeader("X-Requested-With") != null
                && request.getHeader("X-Requested-With").indexOf("XMLHttpRequest") > -1)) {
            return true;
        }
        return false;
    }
}
