Request headers增加参数,直接访问可以获取到,部署到服务器获取不到的原因
参数
access_token:"ddddd";
由于服务器是通过nginx代理转发的,它不认下划线,所以通过nginx代理后后台获取不到
改变参数名或者nginx增加配置
underscores_in_headers on
打印headers的值
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {//根据投信息的key获得值String headVal = request.getHeader("Host");System.out.println("Host:" + headVal);// Host:localhost:8080//通过getHeaderNames获得所有头名字的Enumeration集合Enumeration<String> headNames = request.getHeaderNames();while(headNames.hasMoreElements()){String headName = headNames.nextElement();System.out.println(headName+":"+request.getHeader(headName));}}