__ajax=json 支持添加到 header 里面
This commit is contained in:
@@ -103,12 +103,22 @@ public class ServletUtils {
|
|||||||
public static boolean isAjaxRequest(HttpServletRequest request){
|
public static boolean isAjaxRequest(HttpServletRequest request){
|
||||||
|
|
||||||
String accept = request.getHeader("accept");
|
String accept = request.getHeader("accept");
|
||||||
if (accept != null && accept.indexOf(MediaType.APPLICATION_JSON_VALUE) != -1){
|
if (StringUtils.contains(accept, MediaType.APPLICATION_JSON_VALUE)){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String xRequestedWith = request.getHeader("X-Requested-With");
|
String xRequestedWith = request.getHeader("X-Requested-With");
|
||||||
if (xRequestedWith != null && xRequestedWith.indexOf("XMLHttpRequest") != -1){
|
if (StringUtils.contains(xRequestedWith, "XMLHttpRequest")){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String ajaxHeader = request.getHeader("__ajax");
|
||||||
|
if (StringUtils.inStringIgnoreCase(ajaxHeader, "json", "xml")){
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String ajaxParameter = request.getParameter("__ajax");
|
||||||
|
if (StringUtils.inStringIgnoreCase(ajaxParameter, "json", "xml")){
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -118,11 +128,6 @@ public class ServletUtils {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
String ajax = request.getParameter("__ajax");
|
|
||||||
if (StringUtils.inStringIgnoreCase(ajax, "json", "xml")){
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user