protected boolean isXhrRequest(final HttpServletRequest request) {
        if (StringUtils.hasText(request.getHeader(X_REQUESTED_WITH))) {
            //the X-Requested-With header is present. This is a XHR request
            return true;
        }
        String accessControlRequestHeaders = request.getHeader(ACCESS_CONTROL_REQUEST_HEADERS);
        //One of the requested headers is X-Requested-With so we treat is as XHR request
        return StringUtils.hasText(accessControlRequestHeaders) && containsHeader(accessControlRequestHeaders, X_REQUESTED_WITH);

    }
protected boolean isXhrRequest ( final HttpServletRequest request ) { if ( StringUtils . hasText ( request . getHeader ( X_REQUESTED_WITH ) ) ) { return true ; } String accessControlRequestHeaders = request . getHeader ( ACCESS_CONTROL_REQUEST_HEADERS ) ; return StringUtils . hasText ( accessControlRequestHeaders ) && containsHeader ( accessControlRequestHeaders , X_REQUESTED_WITH ) ; }
Returns true if we believe this is an XHR request
We look for the presence of the X-Requested-With header
or that the X-Requested-With header is listed as a value
in the Access-Control-Request-Headers header.
@param request the HTTP servlet request
@return true if we believe this is an XHR request