Spring Websocket 中的请求或会话范围 [英] Request or Session scope in Spring Websocket

查看:100
本文介绍了Spring Websocket 中的请求或会话范围的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从 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

http:///docs.spring.io/spring/docs/current/spring-framework-reference/htmlsingle/#websocket-stomp-websocket-scope

这篇关于Spring Websocket 中的请求或会话范围的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆