HttpServletRequest request = ServletRequestAttributes RequestContextHoldergetRequestAttributesgetRequest;解析
该语句是用于获取当前请求的 HttpServletRequest 对象。具体解析如下:
-
RequestContextHolder:是 Spring 提供的用于存储和获取请求上下文的工具类,它底层是通过 ThreadLocal 实现的。
-
getRequestAttributes():获取当前请求的 RequestAttributes 对象。
-
ServletRequestAttributes:是 RequestAttributes 的子类,它包含了 HttpServletRequest 和 HttpServletResponse 对象。
-
getRequest():获取当前请求的 HttpServletRequest 对象。
原文地址: https://www.cveoy.top/t/topic/g2SO 著作权归作者所有。请勿转载和采集!