您的位置:首页 > 其它

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

2016-08-18 10:20 260 查看
/**
* @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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: