English 中文(简体)
在最初接收线外接触HttpSession
原标题:Accessing HttpSession outside of the originally receiving thread

I m 当控制员收到申请时,其将控制带<条码>的,附后<条码>@Async,以服务标本,然后返回。 当我在<条码>中查阅。 HttpSession Object I接受这一例外。

java.lang.IllegalStateException: 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/DispatcherPortlet: In 
this case, use RequestContextListener or 
RequestContextFilter to expose the current request.

我如何解决这一问题?

最佳回答

物体本身可在多个深层中使用(但not/strong>thread-safe,因此必须同步进行)。 然而春天正在做一些额外的魔术,例如,当你有<条码>、-镜子。 也就是说,它使用<代码>Thread local underneath使本届会议与校对有约束力。

我不知道你的具体设想是什么,但显然春天试图从这个<条码>上检索,而你却处于另一个线上——这显然已经失败。

解决办法很简单——摘录在@Async中需要,并直接通过。 这正是更好的设计——避免通过<代码>HttpSession<<>>>>/code>,因为它使测试更加困难,而你的代码今后再利用的可能性要小得多。

问题回答

暂无回答




相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...