问题描述
我尝试从 WebSocket 端点调用单例服务.但我无法使用来自 WebSocket 的请求或会话范围.
From WebSocket Endpoint I try to call Singleton Service.But I an unable to use Request or Session scope from WebSocket.
(@Scope(value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS))
(@Scope( value = "request", proxyMode = ScopedProxyMode.TARGET_CLASS))
我得到当前线程的范围请求"未激活;对于任何ScopedProxyMode"上的请求"或会话"范围.
I get Scope 'request' is not active for the current thread;For 'request' or 'session' scope on any 'ScopedProxyMode'.
感谢您的帮助!
推荐答案
对于 Web 套接字,没有请求/响应,因此请求范围无效.他们在 Spring 4.1 中引入了名为 websocket 的新作用域.@Scope(name = "websocket", proxyMode = ScopedProxyMode.TARGET_CLASS).示例参考链接
For web sockets there are no request/response so the request scope is invalid. They introduced new scope called websocket in Spring 4.1. @Scope(name = "websocket", proxyMode = ScopedProxyMode.TARGET_CLASS). Example reference link
这篇关于Spring Websocket 中的请求或会话范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!