spring获取当前request
系列文章目录
springmvc核心流程及配置
springmvc处理模型数据
springmvc返回json
数据绑定
springmvc注解的使用
springmvc异常处理
springmvc拦截器
spring与springmvc整合
使用springSession完成分布式session
spring获取当前request
文章目录
获取当前request
原文链接 https://zhhll.icu/2021/框架/springmvc/基础/9.spring获取当前request/
有时候需要在处理业务的时候用到request对象,可以使用该方法获取
HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
使用RequestContextHolder.currentRequestAttributes()获取的RequestAttributes对象是线程局部变量(ThreadLocal),request对象也是线程局部变量
本文来自博客园,作者:拾光师,转载请注明原文链接:https://www.cnblogs.com/life-time/p/17864328.html 个人博客-> https://zhhll.icu

浙公网安备 33010602011771号