Ajax验证

import javax.servlet.http.HttpServletRequest;

import org.slf4j.Logger;

import org.slf4j.LoggerFactory;

 

public class AjaxUtil

{

  private static final Logger LOGGER = LoggerFactory.getLogger(AjaxUtil.class);

 

  public static boolean checkIsAjax(HttpServletRequest request)

  {

    String requestType = request.getHeader("x-requested-with");

    boolean isAjax = false;

    if ((requestType != null) && (requestType.equals("XMLHttpRequest"))) {

      isAjax = true;

    }

 

    request.setAttribute("isAjax", Boolean.valueOf(isAjax));

    return isAjax;

  }

}

posted on 2019-02-20 17:23  我是司  阅读(475)  评论(0编辑  收藏  举报

导航