restful 风格&判断是不是Ajax请求

来源:互联网 发布:平安银行淘宝卡 白金卡 编辑:程序博客网 时间:2024/06/01 21:54
/**     * @throws ServiceException     * @Title: getAllMenuByView @Description: TODO(获取菜单联动数据) @param     *         modelMap @return @throws     */    @RequestMapping(value = "{path}/home")    public String getLinkageMenu(ModelMap modelMap, HttpServletRequest request,            @PathVariable("path") String path) throws ServiceException {        String url = "/menu/" + path + "/home";        Map<String, Object> map = this.getLinkPage(request, url);        modelMap.putAll(map);        return "widget/common/layout/layout";    }

//判断是不是Ajax请求

    /**    * @Title: isAjaxRequest    * @Description: 判断是否是ajax请求    * @param request    * @return    * @throws    */    private boolean isAjaxRequest(final HttpServletRequest request) {        if (request != null) {            final String accept = request.getHeader("Accept");            if (StringUtils.isNotBlank(accept)) {                if (accept.indexOf(JSON) != -1) {                    return true;                }            }        }        return false;    }


0 0