1.通过方法签名可以直接获取 HttpServletRequest,然后获取请求头信息
2.也可以通过 RequestContextHolder 来获取,具体方式如下
ServletRequestAttributes attrs = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request = attrs.getRequest(); String x = request.getHeader("x");