主要根据http header里的属性x-requested-with进行判断:
//判断是否ajax请求 publicstaticbooleanisAjaxRequest(HttpServletRequestrequest){ if(request.getHeader("x-requested-with")!=null&&request.getHeader("x-requested-with").equalsIgnoreCase("XMLHttpRequest")){ returntrue; } returnfalse; }原文链接:https://www.f2er.com/ajax/162374.html