今天做了个定时批量提交的需求,然后在执行定时任务的时候报了错:
异常信息: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.
之后根据日志定位是子线程里从request里取了header里的字段所以报错,变成参数从方法外面传进去就可以了
本文介绍了在执行定时任务过程中遇到的一个关于请求属性的问题及解决办法。具体表现为在子线程中尝试从HTTP请求中获取header信息时抛出异常,最终通过调整参数传递方式解决了该问题。
1818

被折叠的 条评论
为什么被折叠?



