解决No thread-bound request found: Are you referring to request attributes outside of an actual web...
使用背景:今天在spring-cloud项目中,使用多线程异步调用微服务出现的错误
No thread bound request found: Are you referring to request attributes outside of an actual web request, or processing a request outside of the originally receiving thread? If you are actually operating within a web request and still receive this message, your code is probably running outside of DispatcherServlet: In this case, use RequestContextListener or RequestContextFilter to expose the current request.
具体场景:
为防止响应时间过长,异步处理请求,但是在处理中有FileClient调用
解决思路:
//异步调用,设置子线程共享
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder.getRequestAttributes();
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
RequestContextHolder.setRequestAttributes(servletRequestAttributes,true);//设置子线程共享
//此处你的业务逻辑
});
解决No thread-bound request found: Are you referring to request attributes outside of an actual web...相关推荐
- 解决No thread-bound request found: Are you referring to request attributes outside of an actual web.异常
ServletRequestAttributes servletRequestAttributes = (ServletRequestAttributes) RequestContextHolder. ...
- java web 中有效解决中文乱码问题-pageEncoding与charset区别, response和request的setCharacterEncoding 区别
java web 中有效解决中文乱码问题-pageEncoding与charset区别, response和request的setCharacterEncoding 区别 参考文章: (1)java ...
- setCharacterEncoding 是在request.getParameter获取参数之前 设置request的编码格式 一步到位...
setCharacterEncoding 是在request.getParameter获取参数之前 设置request的编码格式 一步到位 转载于:https://www.cnblogs.com/cl ...
- 总结:request.setAttribute()、session.setAttribute()和request.getParameter()的联系与区别
1.session.setAttribute()和session.getAttribute()配对使用,作用域是整个会话期间,在所有的页面都使用这些数据的时候使用. 2.request.setAttr ...
- Java中request有哪些方法,Java--获取request中所有参数的方法
java获取request中的参数.java解析URL问号后的参数.有时候我们需要从request中获取参数,或者获取拼接在Url后面的参数,有时候一个一个去拿有点麻烦,一起拿出来放在一个map里面需 ...
- request对象的相关方法和获取request对象的方式
request对象相关方法如下: 1.获取客户机环境信息常见方法:: 1.getRequestURL方法返回客户端发出请求时的完整URL.2.getRequestURI方法返回请求行中的资源名部分.3 ...
- 解决Error:403 No valid crumb was included in the request
Jenkins错误备忘:Error:403 No valid crumb was included in the request 在Jenkins上创建流水线后不能save,报这个错. 解决办法: 登 ...
- Xshell 连接报错解决:WARNING! The remote SSH server rejected X11 forwarding request.
一.报错情况 WARNING! The remote SSH server rejected X11 forwarding request. 二.解决方案 (1)编辑文件:/etc/ssh/sshd_ ...
- 解决MySQL报错:LOAD DATA LOCAL INFILE file request rejected due to restrictions on access.
项目场景: 将SQL语句放到一个文件中然后告诉mysql从该文件读取输入,使用cmd命令行读取这个含sql语句的文件 问题描述 使用命令行导入sql语句文件时报错 mysql -u root -p数据 ...
- php怎么取request,PHP-如何在Guzzle中获取Request对象?
我需要使用Guzzle检查数据库中的很多项目.例如,项目数量为2000-5000.将其全部加载到单个数组中太多了,因此我想将其分成多个块:SELECT * FROM items LIMIT100.当最 ...
最新文章
- 2019 Mac装Cocoapods的步(cai)骤(keng)记录
- flask 检测post是否为空_用Flask和Vue制作一个单页应用(五)
- mysql 最大链接数 max_connections 设置
- UITableView 学习笔记
- 修改jupyter的保存位置
- git log 获取构建时间_Docker 运行 Jenkins 自动化构建 .NET Core 项目
- linux 引导程序修复工具,技术|Linux下修改引导器的工具:Boot-Repair
- ES亿级数据检索优化,三秒返回突破性能瓶颈
- Codeforces Global Round 13 C
- c语言编写指针函数求和与两数交换值
- JAVA基础--继承(inheritance)
- (转)别只盯着比特币!“野蛮生长”的ICO江湖:2年30倍只是寻常
- SCSI设备IO栈与块设备并发机制
- ORL人脸数据库matlab,orl ORL人脸数据库,用于图形图像处理,对新接触MATLAB的人来说是一个很好用而且比较简单 238万源代码下载- www.pudn.com...
- 如何看懂公司的财务报表(2)
- 找工作必做事项-剑指offer
- 二手车APP软件开发主要功能
- 数据治理系列(三):主数据管理
- php 新手二维码生成
- XenApp6.5产品BUG
热门文章
- 为了对抗内卷,我“偷”了阿里两份笔记:JDK 源码 +Java 并发图册
- php寄存器是什么意思,tcon是什么寄存器?
- 天呐。怎么修改上传资源积分的?
- STM32F107VCTx HAL库 USART通信 DMA通信 友善串口调试助手 PL2303驱动安装
- linux filp open,Linux Kernel 'do_filp_open()'本地拒绝服务漏洞
- 荣耀4a鸿蒙,华为 Plan B 揭开面纱:鸿蒙要超越安卓?小米 OPPO 们买单吗?
- 京东商品数据分析,教你一键分析数据
- Maven打包war报错
- 论文进入SCI、Ei等国际检索系统的意义(转贴)
- 201809-4 再卖菜(100分)