获取request的两种方式
时间:2021-09-03 23:57:10
收藏:0
阅读:39
1、在filter中获取Request
- HttpServletRequest req = RequestContext.getCurrentContext().getRequest();
- RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
- req = ((ServletRequestAttributes) requestAttributes).getRequest();
2、在controller和service中获取Request
- RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
- req = ((ServletRequestAttributes) requestAttributes).getRequest();
原文:https://www.cnblogs.com/yulongzhang/p/15222533.html
评论(0)