简体   繁体   English

Spring WebSockets @SubscribeMapping中的PathVariables不起作用

[英]PathVariables in Spring WebSockets @SubscribeMapping not working

I am trying to something similar to this " Path variables in Spring WebSockets @SendTo mapping " But I want to send a table name as additional information to @SubscribeMapping("/topic/data"). 我正在尝试与此类似的内容“ Spring WebSockets @SendTo映射中的路径变量 ”,但我想将表名称作为附加信息发送到@SubscribeMapping(“ / topic / data”)。 "tablename" can be anything based on my need(what I want to set), it should concatenate @SubscribeMapping("/topic/data/{tablename}") and on the server side, I would like to access the tablename to get the data from the database. “ tablename”可以是任何基于我的需要(我想设置的东西)的东西,它应该将@SubscribeMapping(“ / topic / data / {tablename}”)连接起来 ,在服务器端,我想访问该表名以获取数据库中的数据。 I have tried the solution mentioned in the above post lien @DestinationVariable but I think I am missing something. 我已经尝试了上述留置权@DestinationVariable中提到的解决方案,但我认为我缺少一些东西。

on the server side : 在服务器端:

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

On the client side 在客户端

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