繁体   English   中英

Spring WebSockets @SubscribeMapping中的PathVariables不起作用

[英]PathVariables in Spring WebSockets @SubscribeMapping not working

我正在尝试与此类似的内容“ Spring WebSockets @SendTo映射中的路径变量 ”,但我想将表名称作为附加信息发送到@SubscribeMapping(“ / topic / data”)。 “ tablename”可以是任何基于我的需要(我想设置的东西)的东西,它应该将@SubscribeMapping(“ / topic / data / {tablename}”)连接起来 ,在服务器端,我想访问该表名以获取数据库中的数据。 我已经尝试了上述留置权@DestinationVariable中提到的解决方案,但我认为我缺少一些东西。

在服务器端:

 @SubscribeMapping("/getviewschema/{tablename}")
 public JSONObject getViewSchema(@DestinationVariable String tablename) throws Exception
 {
     DataManager manager = new DataManager();
     return manager.getViewJSONSchema(tablename);
 }

在客户端

socket.stomp.subscribe("/app/getviewschema/"+service.tablename,function(data) 
{
        listenerview.notify(JSON.parse(data.body));
});  

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM