Java后端获取前端传过来header中的值
Java后端获取前端传过来header中的值比如获取前端传值token值:方法一:不需要在参数中写HttpServletRequest requestServletRequestAttributes attributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();HttpServletReque
·
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");
更多推荐
已为社区贡献3条内容
所有评论(0)