前台Ajax
$.ajax({ type: "post", url: areaComp, dataType: "json", contentType: "application/json", data: data, async: false, //再次添加头部信息 beforeSend: function(request) { request.setRequestHeader("token", token); }, success: function (data){})
后台接收
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attributes.getRequest(); String token=request.getHeader("token");