oauth2获取HttpServletRequest
时间: 2023-10-14 11:03:24 浏览: 108
在使用Hystrix的情况下,通过RequestInterceptor获取HttpServletRequest时,有可能出现获取到的HttpServletRequest为null的情况。这是因为RequestContextHolder中的RequestAttributes是保存在ThreadLocal中,而在子线程中(包括new Thread和new线程池),是无法获取到ThreadLocal中的值的。所以,在新的线程中,尝试获取HttpServletRequest会返回null。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* *3* [Spring Cloud Open Feign系列【22】RequestInterceptor获取不到HttpServletRequest问题解决方案](https://blog.csdn.net/qq_43437874/article/details/122407091)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
- *2* [weChatpay完整版java](https://download.csdn.net/download/asterisk1999/9643686)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT0_1"}}] [.reference_item style="max-width: 50%"]
[ .reference_list ]
阅读全文