Java后端获取前端传过来header中的值
比如获取前端传值token值:
方法一:不需要在参数中写HttpServletRequest request
ServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes(); HttpServletRequest request1 = attributes.getRequest(); String token=request1.getHeader("token");
方法二:需要在参数中写HttpServletRequest request
String token = request.getHeader("token");
标签:HttpServletRequest,Java,前端,request,header,token,传过来 From: https://www.cnblogs.com/Fooo/p/16983966.html