我想创建一个sinlgetom对象,其范围基本上只是request.this将被用来收集错误,我们需要发送错误,当我们发送回应回来..我可以amyone提供指向这个东西? 我也在用春天。
我尝试过使用Spring容器单例对象作用域会话或请求,但仍然mu对象持有较早请求的值
我正在使用AspectJ ..这个错误对象,这可能会导致静态绑定的问题
i want to create a sinlgetom object whose scope is basically only the request.this will be used to collect the errors and we need to send error when ever we send response back.. can i amyone provide pointers toward this thing? i am also using spring.
i tried using Spring container singleton object scope session or request but still mu object is holding values from the earlier request
i am using this error object with AspectJ..is that may cause problem on static binding
最满意答案
我不确定这个单例是否是你想要的 - 如果两个请求同时到达,它们将共享单例对象,并且它们的错误会混淆起来。
是否有可能创建一个对象来保存错误并将其放入一个ThreadLocal对象中。 该对象的范围将受到该请求的约束,并且可以在应用程序内轻松实现对ThreadLocal对象的访问,而无需将引用传递给该对象。
I'm not sure that singleton is what you want here - if two requests arrived concurrently they would share the singleton object, and their errors will get mixed up.
Is it possible to create an object to hold the errors and put that in to a ThreadLocal object. The scope of the object will be constrained by the request, and access to it in the ThreadLocal object is easily achieved from within your application without having to pass a refernce to the object around.
更多推荐
发布评论