Spring WebSockets中的PathVariables @SubscribeMapping不起作用

[英]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"). "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. I have tried the solution mentioned in the above post lien @DestinationVariable but I think I am missing something.

我正在嘗試類似於“Spring WebSockets @SendTo映射中的路徑變量”但我想將表名作為附加信息發送到@SubscribeMapping(“/ topic / data”)。 “tablename”可以是基於我的需要(我想要設置的),它應該連接@SubscribeMapping(“/ topic / data / {tablename}”)並且在服務器端,我想訪問tablename以獲取來自數據庫的數據。我已經嘗試過上面帖子lien @DestinationVariable中提到的解決方案,但我想我錯過了一些東西。

1 个解决方案

#1


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));
});  

注意!

本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2015/05/08/af72673944a838c00a6cb53a3e7fe7d5.html



 
  © 2014-2022 ITdaan.com 联系我们: