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

/**
     * @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 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;
    }


你可能感兴趣的:(javaweb)