请注意,在使用 RequestContextHolder 时,确保上下文中包含请求信息,否则可能会出现空指针非常。别的,这种方式适用于基于 Spring MVC 或 Spring WebFlux 的应用。