判断是否ajax请求

/**
 * 判断ajax请求
 * @param request
 * @return
 */
boolean isAjax(HttpServletRequest request){
    return  (request.getHeader("X-Requested-With") != null  && "XMLHttpRequest".equals( request.getHeader("X-Requested-With").toString())   ) ;
}
 
ajax返回值有<pre>标签时,ajax添加属性dataType为text类型即可!

相关推荐