web后端判断是否ajax请求

String requestType = httpServletRequest.getHeader("X-Requested-With");  

boolean isAjax = "XMLHttpRequest".equals(requestType);

if(isAjax){

 // 是ajax异步请求

}else{

// 不是ajax异步请求

}

扫描二维码关注公众号,回复: 345053 查看本文章

说明:据说上述方法不是百分之百的准确,使用时需注意。

猜你喜欢

转载自huangqiqing123.iteye.com/blog/2262381
今日推荐